[m-rev.] diff: more cleanups
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Oct 12 11:27:33 AEST 2005
compiler/hlds_out.m:
Write out more information about construction unifications.
compiler/mark_static_terms.m:
compiler/mlds.m:
Convert to four space indentation. Fix departures from our coding
standards.
compiler/mode_constraints.m:
Minor cleanups.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.371
diff -u -b -r1.371 hlds_out.m
--- compiler/hlds_out.m 10 Oct 2005 07:54:35 -0000 1.371
+++ compiler/hlds_out.m 11 Oct 2005 15:16:55 -0000
@@ -2313,7 +2313,7 @@
mercury_output_var(Y, ProgVarSet, AppendVarNums, !IO),
io__write_string("\n", !IO).
-write_unification(construct(Var, ConsId, ArgVars, ArgModes, _ConstructHow,
+write_unification(construct(Var, ConsId, ArgVars, ArgModes, ConstructHow,
Uniqueness, SubInfo), ModuleInfo, ProgVarSet, InstVarSet,
AppendVarNums, Indent, !IO) :-
write_indent(Indent, !IO),
@@ -2360,6 +2360,22 @@
;
MaybeSize = no
)
+ ),
+ (
+ ConstructHow = construct_dynamically
+ ;
+ ConstructHow = construct_statically(StaticConsList),
+ write_indent(Indent, !IO),
+ io__write_string("% construct statically\n", !IO),
+ list__foldl(write_static_cons(Indent, 1, ProgVarSet, AppendVarNums),
+ StaticConsList, !IO)
+ ;
+ ConstructHow = reuse_cell(CellToReuse),
+ CellToReuse = cell_to_reuse(ReuseVar, _ReuseConsIds, _FieldAssigns),
+ write_indent(Indent, !IO),
+ io__write_string("% reuse cell: ", !IO),
+ mercury_output_var(ReuseVar, ProgVarSet, AppendVarNums, !IO),
+ io__write_string("\n", !IO)
).
write_unification(deconstruct(Var, ConsId, ArgVars, ArgModes, CanFail, CanCGC),
@@ -2404,6 +2420,29 @@
io__write_string("% type-info vars: ", !IO),
mercury_output_vars(TypeInfoVars, ProgVarSet, AppendVarNums, !IO),
io__write_string("\n", !IO).
+
+:- pred write_static_cons(int::in, int::in, prog_varset::in, bool::in,
+ static_cons::in, io::di, io::uo) is det.
+
+write_static_cons(Indent, Depth, VarSet, AppendVarNums, StaticCons, !IO) :-
+ StaticCons = static_cons(ConsId, ArgVars, ArgStaticConstList),
+ write_indent(Indent, !IO),
+ io__write_string("% ", !IO),
+ write_indent(Depth, !IO),
+ mercury_output_cons_id(ConsId, does_not_need_brackets, !IO),
+ io__write_string("\n", !IO),
+ (
+ ArgVars = []
+ ;
+ ArgVars = [_ | _],
+ write_indent(Indent, !IO),
+ io__write_string("% ", !IO),
+ write_indent(Depth, !IO),
+ mercury_output_vars(ArgVars, VarSet, AppendVarNums, !IO),
+ io__write_string("\n", !IO)
+ ),
+ list__foldl(write_static_cons(Indent, Depth + 1, VarSet, AppendVarNums),
+ ArgStaticConstList, !IO).
:- pred write_functor_and_submodes(cons_id::in, list(prog_var)::in,
list(uni_mode)::in, module_info::in, prog_varset::in, inst_varset::in,
Index: compiler/mark_static_terms.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mark_static_terms.m,v
retrieving revision 1.16
diff -u -b -r1.16 mark_static_terms.m
--- compiler/mark_static_terms.m 24 Mar 2005 05:34:07 -0000 1.16
+++ compiler/mark_static_terms.m 11 Oct 2005 15:23:17 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 2000-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.
@@ -30,28 +32,24 @@
:- import_module hlds__hlds_data.
:- import_module hlds__hlds_goal.
+:- import_module parse_tree__error_util.
:- import_module parse_tree__prog_data.
:- import_module bool.
-:- import_module list.
-:- import_module map.
-
-%
-% As we traverse the goal, we keep track of which variables are static at
-% this point, and for each such variable, we keep information on how to
-% construct it.
-%
-:- type static_info == map(prog_var, static_cons).
-
-:- import_module hlds__hlds_goal.
-
:- import_module int.
:- import_module list.
+:- import_module map.
:- import_module require.
:- import_module std_util.
+:- import_module svmap.
+
+ % As we traverse the goal, we keep track of which variables are static
+ % at the current program point, and for each such variable, we keep
+ % information on how to construct it.
+:- type static_info == map(prog_var, static_cons).
mark_static_terms(_ModuleInfo, !Proc) :-
- % The ModuleInfo argument is there just for passes_aux
+ % The ModuleInfo argument is there just for passes_aux.
proc_info_goal(!.Proc, Goal0),
map__init(StaticInfo0),
goal_mark_static_terms(Goal0, Goal, StaticInfo0, _StaticInfo),
@@ -70,22 +68,21 @@
conj_mark_static_terms(Goals0, Goals, !SI).
goal_expr_mark_static_terms(par_conj(Goals0), par_conj(Goals), !SI) :-
- % it's OK to treat parallel conjunctions as if they were
- % sequential here, since if we mark any variables as
- % static, the computation of those variables will be
- % done at compile time.
+ % It's OK to treat parallel conjunctions as if they were sequential here,
+ % since if we mark any variables as static, the computation of those
+ % variables will be done at compile time.
conj_mark_static_terms(Goals0, Goals, !SI).
goal_expr_mark_static_terms(disj(Goals0), disj(Goals), !SI) :-
- % we revert to the original static_info at the end of branched goals
+ % We revert to the original static_info at the end of branched goals.
disj_mark_static_terms(Goals0, Goals, !.SI).
goal_expr_mark_static_terms(switch(A, B, Cases0), switch(A, B, Cases), !SI) :-
- % we revert to the original static_info at the end of branched goals
+ % We revert to the original static_info at the end of branched goals.
cases_mark_static_terms(Cases0, Cases, !.SI).
goal_expr_mark_static_terms(not(Goal0), not(Goal), !SI) :-
- % we revert to the original static_info at the end of the negation
+ % We revert to the original static_info at the end of the negation.
goal_mark_static_terms(Goal0, Goal, !.SI, _SI).
goal_expr_mark_static_terms(scope(A, Goal0), scope(A, Goal), !SI) :-
@@ -93,10 +90,9 @@
goal_expr_mark_static_terms(if_then_else(A, Cond0, Then0, Else0),
if_then_else(A, Cond, Then, Else), SI0, SI0) :-
- % we run the Cond and the Then in sequence,
- % and we run the Else in parallel with that,
- % and then we throw away the static_infos we computed
- % and revert to the original static_info at the end,
+ % We run the Cond and the Then in sequence, and we run the Else
+ % in parallel with that, and then we throw away the static_infos
+ % we computed and revert to the original static_info at the end,
% since this was a branched goal.
goal_mark_static_terms(Cond0, Cond, SI0, SI_Cond),
goal_mark_static_terms(Then0, Then, SI_Cond, _SI_Then),
@@ -113,8 +109,8 @@
goal_expr_mark_static_terms(Goal @ foreign_proc(_, _, _, _, _, _), Goal, !SI).
goal_expr_mark_static_terms(shorthand(_), _, !SI) :-
- % these should have been expanded out by now
- error("fill_expr_slots: unexpected shorthand").
+ % These should have been expanded out by now.
+ unexpected(this_file, "fill_expr_slots: unexpected shorthand").
:- pred conj_mark_static_terms(hlds_goals::in, hlds_goals::out,
static_info::in, static_info::out) is det.
@@ -127,7 +123,7 @@
disj_mark_static_terms([], [], _).
disj_mark_static_terms([Goal0 | Goals0], [Goal | Goals], SI0) :-
- % we throw away the static_info obtained after each branch
+ % We throw away the static_info obtained after each branch.
goal_mark_static_terms(Goal0, Goal, SI0, _SI),
disj_mark_static_terms(Goals0, Goals, SI0).
@@ -137,49 +133,41 @@
cases_mark_static_terms([], [], _SI0).
cases_mark_static_terms([Case0 | Cases0], [Case | Cases], SI0) :-
Case0 = case(ConsId, Goal0),
- Case = case(ConsId, Goal),
- % we throw away the static_info obtained after each branch
+ % We throw away the static_info obtained after each branch.
goal_mark_static_terms(Goal0, Goal, SI0, _SI),
+ Case = case(ConsId, Goal),
cases_mark_static_terms(Cases0, Cases, SI0).
:- pred unification_mark_static_terms(unification::in, unification::out,
static_info::in, static_info::out) is det.
-unification_mark_static_terms(Unification0, Unification,
- StaticVars0, StaticVars) :-
+unification_mark_static_terms(Unification0, Unification, !StaticVars) :-
(
- Unification0 = construct(Var, ConsId, ArgVars, D,
- HowToConstruct0, F, G),
+ Unification0 = construct(Var, ConsId, ArgVars, D, HowToConstruct0,
+ F, G),
(
- % if all the arguments are static,
- % then the newly constructed variable
- % is static too
- CheckStaticArg = (pred(V::in, C::out) is semidet :-
- map__search(StaticVars0, V, C)),
- list__map(CheckStaticArg, ArgVars, StaticArgs)
+ % If all the arguments are static, then the newly constructed
+ % variable is static too.
+ list__map(map__search(!.StaticVars), ArgVars, StaticArgs)
->
HowToConstruct = construct_statically(StaticArgs),
- map__det_insert(StaticVars0, Var,
- static_cons(ConsId, ArgVars, StaticArgs),
- StaticVars)
+ svmap__det_insert(Var, static_cons(ConsId, ArgVars, StaticArgs),
+ !StaticVars)
;
- HowToConstruct = HowToConstruct0,
- StaticVars = StaticVars0
+ HowToConstruct = HowToConstruct0
),
( HowToConstruct = HowToConstruct0 ->
- % this is a minor optimization to improve the
- % efficiency of the compiler: don't bother
- % allocating memory if we don't need to
+ % This is a minor optimization to improve the efficiency of the
+ % compiler: don't bother allocating memory if we don't need to.
Unification = Unification0
;
- Unification = construct(Var, ConsId, ArgVars, D,
- HowToConstruct, F, G)
+ Unification = construct(Var, ConsId, ArgVars, D, HowToConstruct,
+ F, G)
)
;
Unification0 = deconstruct(_Var, _ConsId, _ArgVars, _UniModes,
_CanFail, _CanCGC),
- Unification = Unification0,
- StaticVars = StaticVars0
+ Unification = Unification0
% (
% % if the variable being deconstructed is static,
% % and the deconstruction cannot fail,
@@ -191,27 +179,32 @@
% ->
% XXX insert ArgVars into StaticVars0
% ;
-% StaticVars = StaticVars0
+% true
% )
;
Unification0 = assign(TargetVar, SourceVar),
Unification = Unification0,
(
- % if the variable being assign from is static,
- % then the variable being assigned to is static too
- map__search(StaticVars0, SourceVar, Data)
+ % If the variable being assign from is static,
+ % then the variable being assigned to is static too.
+ map__search(!.StaticVars, SourceVar, Data)
->
- map__det_insert(StaticVars0, TargetVar, Data,
- StaticVars)
+ svmap__det_insert(TargetVar, Data, !StaticVars)
;
- StaticVars = StaticVars0
+ true
)
;
Unification0 = simple_test(_, _),
- Unification = Unification0,
- StaticVars = StaticVars0
+ Unification = Unification0
;
Unification0 = complicated_unify(_, _, _),
- Unification = Unification0,
- StaticVars = StaticVars0
+ Unification = Unification0
).
+
+%-----------------------------------------------------------------------------%
+
+:- func this_file = string.
+
+this_file = "mark_static_terms.m".
+
+%-----------------------------------------------------------------------------%
Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.123
diff -u -b -r1.123 mlds.m
--- compiler/mlds.m 30 Sep 2005 08:08:27 -0000 1.123
+++ compiler/mlds.m 11 Oct 2005 15:16:55 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 1999-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.
@@ -259,7 +261,7 @@
% command-line completion works even for mangled names (and hopefully
% even shows all the possible alternatives...).]
%
-% To avoid ambiguity as to whether a name is qualified or not,,
+% To avoid ambiguity as to whether a name is qualified or not,
% any procedures whose unqualified name matches the pattern for qualified
% names, i.e. the regular expression `.*_[fp][0-9]*(_[0-9]+)?(_i[0-9]+)?',
% should always be qualified (even if not overloaded).
@@ -395,16 +397,15 @@
---> user_visible_interface
; compiler_visible_interface.
-% An mlds__import specifies FIXME
-% Currently an import just gives the name of the package to be imported.
-% This might perhaps need to be expanded to cater to different kinds of
-% imports, e.g. imports with wild-cards ("import java.lang.*").
+ % An mlds__import specifies FIXME
+ % Currently an import just gives the name of the package to be imported.
+ % This might perhaps need to be expanded to cater to different kinds of
+ % imports, e.g. imports with wild-cards ("import java.lang.*").
:- type mlds__import
---> mercury_import(
mercury_mlds_import_type :: mercury_mlds_import_type,
import_name :: mlds_module_name
)
-
; foreign_import(
foreign_import_name :: foreign_import_name
).
@@ -412,65 +413,79 @@
:- type foreign_import_name
---> il_assembly_name(mlds_module_name).
-% An mlds_module_name specifies the name of an mlds package or class.
+ % An mlds_module_name specifies the name of an mlds package or class.
:- type mlds_module_name.
-% An mlds__package_name specifies the name of an mlds package.
+ % An mlds__package_name specifies the name of an mlds package.
:- type mlds__package_name == mlds_module_name.
-% Given the name of a Mercury module, return the name of the corresponding
-% MLDS package in which this module is defined.
+ % Given the name of a Mercury module, return the name of the corresponding
+ % MLDS package in which this module is defined.
+ %
:- func mercury_module_name_to_mlds(mercury_module_name) = mlds_module_name.
-% Given the name of a Mercury module, and a package name, return the
-% name of the corresponding MLDS module name in which this module is
-% defined.
-% In this case, the package is specified as the first parameter (c.f.
-% mercury_module_name_to_mlds above).
+ % Given the name of a Mercury module, and a package name, return the
+ % name of the corresponding MLDS module name in which this module is
+ % defined.
+ % In this case, the package is specified as the first parameter (c.f.
+ % mercury_module_name_to_mlds above).
+ %
:- func mercury_module_and_package_name_to_mlds(mercury_module_name,
mercury_module_name) = mlds_module_name.
-% Given the name of a Mercury module return the fully qualified module
-% name. ie For the name System.Object which is defined in the source
-% package mscorlib it will return System.Object.
+ % Given the name of a Mercury module return the fully qualified module
+ % name, e.g. for the name System.Object which is defined in the source
+ % package mscorlib, it will return System.Object.
+ %
:- func mlds_module_name_to_sym_name(mlds__package_name) = sym_name.
-% Give the name of a Mercury module, return the name of the corresponding
-% MLDS package.
+ % Give the name of a Mercury module, return the name of the corresponding
+ % MLDS package.
+ %
:- func mlds_module_name_to_package_name(mlds_module_name) = sym_name.
-% Is the current module a member of the std library,
-% and if so which module is it?
+ % Is the current module a member of the std library,
+ % and if so which module is it?
+ %
:- pred is_std_lib_module(mlds_module_name::in, string::out) is semidet.
-% Given an MLDS module name (e.g. `foo.bar'), append another class qualifier
-% (e.g. for a class `baz'), and return the result (e.g. `foo.bar.baz').
-% The `arity' argument specifies the arity of the class.
-% The qual_kind argument specifies the qualifier kind of the module_name
-% argument.
+ % Given an MLDS module name (e.g. `foo.bar'), append another class
+ % qualifier (e.g. for a class `baz'), and return the result (e.g.
+ % `foo.bar.baz'). The `arity' argument specifies the arity of the class.
+ % The qual_kind argument specifies the qualifier kind of the module_name
+ % argument.
+ %
:- func mlds__append_class_qualifier(mlds_module_name, mlds__qual_kind,
globals, mlds__class_name, arity) = mlds_module_name.
-% Append a wrapper class qualifier to the module name and leave the
-% package name unchanged.
+ % Append a wrapper class qualifier to the module name and leave the
+ % package name unchanged.
+ %
:- func mlds__append_wrapper_class(mlds_module_name) = mlds_module_name.
-% Append an arbitrary qualifier to the module name and leave the package
-% name unchanged.
+ % Append an arbitrary qualifier to the module name and leave the package
+ % name unchanged.
+ %
:- func mlds__append_name(mlds_module_name, string) = mlds_module_name.
-% When targetting languages such as IL, C#, and Java, which don't
-% support global methods or global variables, we need to wrap all the
-% generated global functions and global data inside a wrapper class.
-% This function returns the name to use for the wrapper class.
+ % When targetting languages such as IL, C#, and Java, which don't support
+ % global methods or global variables, we need to wrap all the generated
+ % global functions and global data inside a wrapper class. This function
+ % returns the name to use for the wrapper class.
+ %
:- func wrapper_class_name = string.
:- type mlds__defns == list(mlds__defn).
+
:- type mlds__defn
---> mlds__defn(
- mlds__entity_name, % the name of the entity being declared
- mlds__context, % the source location
- mlds__decl_flags, % these contain the following:
+ % The name of the entity being declared.
+ mlds_entity_name :: mlds__entity_name,
+
+ % The source location.
+ mlds_context :: mlds__context,
+
+ % these contain the following:
% mlds__access, % public/private/protected
% mlds__member_type, % static/per_instance
% mlds__virtuality, % virtual/non_virtual
@@ -478,20 +493,24 @@
% mlds__constness, % const/modifiable (data only)
% mlds__is_abstract, % abstract/concrete
% etc.
- mlds__entity_defn % the definition of the entity
+ mlds_decl_flags :: mlds__decl_flags,
+
+ mlds_entity_defn :: mlds__entity_defn
).
-% An mlds name may contain arbitrary characters.
-% If the target language has restrictions on what names can be used
-% in identifiers, then it is the responsibility of the target language
-% generator to mangle these names accordingly.
+ % An mlds name may contain arbitrary characters.
+ % If the target language has restrictions on what names can be used
+ % in identifiers, then it is the responsibility of the target language
+ % generator to mangle these names accordingly.
:- type mlds__qualified_entity_name
== mlds__fully_qualified_name(mlds__entity_name).
+
:- type mlds__fully_qualified_name(T)
---> qual(mlds_module_name, mlds__qual_kind, T).
-% For the Java back-end, we need to distinguish between module qualifiers
-% and type qualifiers, because type names get the case of their initial
-% letter inverted (i.e. lowercase => uppercase).
+
+ % For the Java back-end, we need to distinguish between module qualifiers
+ % and type qualifiers, because type names get the case of their initial
+ % letter inverted (i.e. lowercase => uppercase).
:- type mlds__qual_kind
---> module_qual
; type_qual.
@@ -500,27 +519,28 @@
---> type(mlds__class_name, arity) % Name, arity.
; data(mlds__data_name)
; function(
- mlds__pred_label, % Identifies the source code
- % predicate or function.
+ % Identifies the source code predicate or function.
+ mlds__pred_label,
- proc_id, % Mode number.
+ proc_id,
- % A sequence number used to distinguish
- % different MLDS functions when compiling a
- % single HLDS predicate into multiple MLDS
- % functions (e.g. to handle backtracking).
+ % A sequence number used to distinguish different MLDS
+ % functions when compiling a single HLDS predicate into
+ % multiple MLDS functions (e.g. to handle backtracking).
maybe(mlds__func_sequence_num),
- % This should generally not be needed much,
- % since all the necessary information should
- % be in the mlds__pred_label and/or in the
- % mlds__entity_defn. However, the target
- % generator may want to refer to the HLDS
- % for additional information.
- pred_id % Specifies the HLDS pred_id.
+ % Specifies the HLDS pred_id.
+ % This should generally not be needed much, since all the
+ % necessary information should be in the mlds__pred_label
+ % and/or in the mlds__entity_defn. However, the target
+ % generator may want to refer to the HLDS for additional
+ % information.
+ pred_id
)
- ; export(string) % A pragma export name.
- .
+ ; export(
+ % A pragma export name.
+ string
+ ).
:- type mlds__func_sequence_num == int.
@@ -534,25 +554,26 @@
% struct (value class)
% enum
:- type mlds__entity_defn
- % constants or variables
---> mlds__data(
+ % Represents a constant or variable.
+
mlds__type,
mlds__initializer,
- % If accurate GC is enabled, we associate
- % with each variable the code needed to
- % trace that variable when doing GC.
+ % If accurate GC is enabled, we associate with each variable
+ % the code needed to trace that variable when doing GC.
mlds__maybe_gc_trace_code
)
- % functions
; mlds__function(
- maybe(pred_proc_id), % identifies the original
- % Mercury procedure, if any
- mlds__func_params, % the arguments & return types
- mlds__function_body, % the function body
- list(mlds__attribute) % attributes
+ % Represents functions.
+
+ maybe(pred_proc_id), % Identifies the original
+ % Mercury procedure, if any.
+ mlds__func_params, % The arguments & return types.
+ mlds__function_body, % The function body.
+ list(mlds__attribute) % Attributes.
)
- % packages, classes, interfaces, structs, enums
; mlds__class(
+ % Represents packages, classes, interfaces, structs, enums.
mlds__class_defn
).
@@ -580,22 +601,23 @@
---> init_obj(mlds__rval)
; init_struct(mlds__type, list(mlds__initializer))
; init_array(list(mlds__initializer))
- ; no_initializer
- .
+ ; no_initializer.
:- type mlds__func_params
---> mlds__func_params(
mlds__arguments, % names and types of arguments (inputs)
mlds__return_types % types of return values (outputs)
).
+
:- type mlds__arguments == list(mlds__argument).
:- type mlds__argument
---> mlds__argument(
mlds__entity_name, % argument name
mlds__type, % argument type
- mlds__maybe_gc_trace_code % GC tracing code for this
- % argument, if needed
+ mlds__maybe_gc_trace_code % GC tracing code for this argument,
+ % if needed
).
+
:- type mlds__arg_types == list(mlds__type).
:- type mlds__return_types == list(mlds__type).
@@ -613,25 +635,22 @@
:- func mlds__get_func_signature(mlds__func_params) = mlds__func_signature.
:- type mlds__class_kind
- ---> mlds__class % A generic class:
- % can inherit other classes and
- % interfaces
- % (but most targets will only support
- % single inheritence, so usually there
- % will be at most one class).
- ; mlds__package % A class with only static members
- % (can only inherit other packages).
- % Unlike other kinds of classes,
- % packages should not be used as types.
- ; mlds__interface % A class with no variable data members
- % (can only inherit other interfaces)
- ; mlds__struct % A value class
- % (can only inherit other structs).
- ; mlds__enum % A class with one integer member and
- % a bunch of static consts
- % (cannot inherit anything).
- .
+ ---> mlds__class % A generic class: can inherit other classes and
+ % interfaces (but most targets will only support
+ % single inheritence, so usually there will be
+ % at most one class).
+
+ ; mlds__package % A class with only static members (can only
+ % inherit other packages). Unlike other kinds
+ % of classes, packages should not be used as types.
+ ; mlds__interface % A class with no variable data members (can only
+ % inherit other interfaces).
+
+ ; mlds__struct % A value class (can only inherit other structs).
+
+ ; mlds__enum. % A class with one integer member and a bunch
+ % of static consts (cannot inherit anything).
:- type mlds__class_name == string.
:- type mlds__class == mlds__fully_qualified_name(mlds__class_name).
@@ -643,32 +662,37 @@
:- type mlds__class_defn
---> mlds__class_defn(
kind :: mlds__class_kind,
- imports :: mlds__imports, % imports these classes (or
- % modules, packages, ...)
+ imports :: mlds__imports,
+ % Imports these classes (or modules, packages, ...).
+
inherits :: list(mlds__class_id),
- % inherits these base classes
+ % Inherits these base classes.
+
implements :: list(mlds__interface_id),
- % implements these interfaces
- ctors :: mlds__defns, % has these constructors
- members :: mlds__defns % contains these members
+ % Implements these interfaces.
+
+ ctors :: mlds__defns,
+ % Has these constructors.
+
+ members :: mlds__defns
+ % Contains these members.
).
% Note: the definition of the `mlds__type' type is subject to change.
% In particular, we might add new alternatives here, so try to avoid
% switching on this type.
:- type mlds__type
- ---> % Mercury data types
- mercury_type(
- prog_data__type, % the exact Mercury type
- type_category, % what kind of type it is:
- % enum, float, etc.
- exported_type % a representation of the type
- % which can be used to
- % determine the foreign
- % language representation of
- % the type.
+ ---> mercury_type(
+ % Mercury data types
+
+ prog_data__type, % The exact Mercury type.
+ type_category, % What kind of type it is: enum, float, ...
+ exported_type % A representation of the type which can be
+ % used to determine the foreign language
+ % representation of the type.
)
+ ; mlds__mercury_array_type(mlds__type)
% The Mercury array type is treated specially, some backends
% will treat it like any other mercury_type, whereas other may
% use a special representation for it.
@@ -681,12 +705,12 @@
% Note that mlds__mercury_array_type/1 is used for representing
% Mercury arrays, whereas mlds__array_type/1 (see below)
% is used for representing the target language's native arrays.
- ; mlds__mercury_array_type(mlds__type)
- % The type for the continuation functions used
- % to handle nondeterminism
; mlds__cont_type(mlds__return_types)
+ % The type for the continuation functions used to handle
+ % nondeterminism
+ ; mlds__commit_type
% mlds__commit_type is used for storing information about a
% commit. This is an abstract type; the exact definition
% will depend on the back-end. The only operations on this ADT
@@ -710,29 +734,30 @@
%
% See also the comments in ml_code_gen.m which show how commits
% can be implemented for different target languages.
- ; mlds__commit_type
- % MLDS native builtin types.
- % These are the builtin types of the MLDS target language,
- % whatever that may be.
- % Currently we don't actually use many of these.
; mlds__native_bool_type
; mlds__native_int_type
; mlds__native_float_type
; mlds__native_char_type
+ % MLDS native builtin types.
+ % These are the builtin types of the MLDS target language,
+ % whatever that may be.
+ % Currently we don't actually use many of these.
- % This is a type of the target language.
; mlds__foreign_type(
+ % This is a type of the target language.
foreign_language_type
)
- % MLDS types defined using mlds__class_defn
; mlds__class_type(
+ % MLDS types defined using mlds__class_defn.
+
mlds__class, % name
arity,
mlds__class_kind
)
+ ; mlds__array_type(mlds__type)
% MLDS array types.
% These are single-dimensional, and can be indexed
% using the `field' lval with an `offset' field_id;
@@ -754,30 +779,26 @@
% (c) for any other arrays generated internally by the
% MLDS code generator, e.g. the arrays used for
% string switches.
- ; mlds__array_type(mlds__type)
+ ; mlds__ptr_type(mlds__type)
% Pointer types.
% Currently these are used for handling output arguments.
- ; mlds__ptr_type(mlds__type)
- % Function types.
- % For the C back-end, these are mapped to function
- % pointer types, since C doesn't have first-class
- % function types.
; mlds__func_type(mlds__func_params)
+ % Function types.
+ % For the C back-end, these are mapped to function pointer types,
+ % since C doesn't have first-class function types.
+ ; mlds__generic_type
% A generic type (e.g. `Word') that can hold any Mercury value.
% This is used for implementing polymorphism.
- ; mlds__generic_type
- % A generic pointer type (e.g. `void *' in C)
- % that can be used to point to the environment
- % (set of local variables) of the containing function.
- % This is used for handling nondeterminism,
- % if the target language doesn't support
- % nested functions, and also for handling
- % closures for higher-order code.
; mlds__generic_env_ptr_type
+ % A generic pointer type (e.g. `void *' in C) that can be used
+ % to point to the environment (set of local variables) of the
+ % containing function. This is used for handling nondeterminism,
+ % if the target language doesn't support nested functions, and
+ % also for handling closures for higher-order code.
; mlds__type_info_type
@@ -785,18 +806,17 @@
; mlds__rtti_type(rtti_id_maybe_element)
- % A type used by the ML code generator for references
- % to variables that have yet to be declared. This occurs
- % once in ml_code_util.m where references to env_ptr's are
- % generated but the declaration of these env_ptr's does not
- % occur until the ml_elim_nested pass.
; mlds__unknown_type.
+ % A type used by the ML code generator for references to variables
+ % that have yet to be declared. This occurs once in ml_code_util.m
+ % where references to env_ptr's are generated but the declaration
+ % of these env_ptr's does not occur until the ml_elim_nested pass.
:- type mercury_type == prog_data__type.
:- func mercury_type_to_mlds_type(module_info, mercury_type) = mlds__type.
-% Hmm... this is tentative.
+ % Hmm... this is tentative.
:- type mlds__class_id == mlds__type.
:- type mlds__interface_id == mlds__type.
@@ -808,35 +828,30 @@
:- type mlds__decl_flags.
:- type access
- %
- % used for class members (this includes globals,
+ % The following used for class members (this includes globals,
% which are actually members of the top-level package)
- %
- ---> public % accessible to anyone
- ; protected % only accessible to the class and to
- % derived classes
- ; private % only accessible to the class
- ; default % Java "default" access or .NET assembly
- % access: accessible to anything defined
- % in the same package.
- %
- % Used for entities defined in a block/2 statement,
+
+ ---> public % Accessible to anyone.
+ ; protected % Only accessible to the class and to derived classes.
+ ; private % Only accessible to the class.
+ ; default % Java "default" access or .NET assembly access:
+ % accessible to anything defined in the same package.
+
+ % The following is used for entities defined in a block/2 statement,
% i.e. local variables and nested functions.
- %
- ; local % only accessible within the block
- % in which the entity (variable or
- % nested function) is defined
- .
+
+ ; local. % Only accessible within the block in which the entity
+ % (variable or nested function) is defined.
:- type per_instance
- ---> one_copy % i.e. "static" storage duration
- % (but not necessarily static linkage)
- % or static member function
- % Note that `one_copy' variables
- % *must* have an initializer
+ ---> one_copy % I.e. "static" storage duration (but not necessarily
+ % static linkage) or static member function. Note that
+ % `one_copy' variables *must* have an initializer
% (the GCC back-end relies on this.)
- ; per_instance. % i.e. "auto" local variable in function,
- % or non-static member of class.
+
+ ; per_instance.
+ % I.e. "auto" local variable in function, or non-static
+ % member of class.
:- type virtuality
---> non_virtual
@@ -874,14 +889,11 @@
%-----------------------------------------------------------------------------%
%
% Foreign code interfacing
-%
- %
% Foreign code required for the foreign language interface.
% When compiling to a language other than the foreign language,
% this part still needs to be generated as C (or whatever) code
% and compiled with a C (or whatever) compiler.
- %
:- type mlds__foreign_code
---> mlds__foreign_code(
foreign_decl_info,
@@ -890,10 +902,7 @@
list(mlds__pragma_export)
).
- %
- % Information required to generate code for each
- % `pragma export'.
- %
+ % Information required to generate code for each `pragma export'.
:- type mlds__pragma_export
---> ml_pragma_export(
string, % Exported name
@@ -905,7 +914,6 @@
%-----------------------------------------------------------------------------%
%
% Attributes
-%
:- type mlds__attribute
---> custom(
@@ -915,9 +923,8 @@
%-----------------------------------------------------------------------------%
%
% Contexts (i.e. source code locations)
-%
- % mlds__context is probably == prog_context,
+ % Mlds__context is probably == prog_context,
% but might also contain goal_path or other information.
:- type mlds__context.
@@ -939,29 +946,23 @@
).
:- type mlds__stmt
- --->
+ % Sequence.
- %
- % sequence
- %
- block(mlds__defns, list(mlds__statement))
+ ---> block(mlds__defns, list(mlds__statement))
+
+ % Iteration.
- %
- % iteration
- %
; while(mlds__rval, mlds__statement, bool)
- % the `bool' is true iff the loop is guaranteed
- % to iterate at least once -- in that case,
- % the compiler can generate a `do...while' loop
- % rather than a `while...' loop.
+ % The `bool' is true iff the loop is guaranteed to iterate at
+ % least once -- in that case, the compiler can generate a
+ % `do...while' loop rather than a `while...' loop.
- %
- % selection (see also computed_goto)
- %
- ; if_then_else(mlds__rval, mlds__statement,
- maybe(mlds__statement))
+ % Selection (see also computed_goto).
+
+ ; if_then_else(mlds__rval, mlds__statement, maybe(mlds__statement))
+ ; switch(
% This representation for switches is very general:
% it allows switching on any type, and cases can match
% on ranges as well as on values.
@@ -974,64 +975,57 @@
%
% Note that unlike C, MLDS cases do NOT fall through; if you
% want to achieve that effect, you need to use an explicit goto.
- ; switch(
+
% The value to switch on
mlds__type,
mlds__rval,
- % The range of possible values which the
- % value might take (if known)
+ % The range of possible values which the value might take
+ % (if known).
mlds__switch_range,
- % The different cases
+ % The different cases.
mlds__switch_cases,
- % What to do if none of the cases match
+ % What to do if none of the cases match.
mlds__switch_default
)
- %
- % transfer of control
- %
+ % Transfer of control.
; label(mlds__label)
- % Defines a label that can be used as the
- % target of calls, gotos, etc.
+ % Defines a label that can be used as the target of calls,
+ % gotos, etc.
; goto(mlds__goto_target)
- % goto(Target)
- % Branch to the specified address.
+ % goto(Target): Branch to the specified address.
; computed_goto(mlds__rval, list(mlds__label))
- % Evaluate rval, which should be an integer,
- % and jump to the (rval+1)th label in the list.
- % e.g. computed_goto(2, [A, B, C, D])
+ % Evaluate rval, which should be an integer, and jump to the
+ % (rval+1)th label in the list. e.g. computed_goto(2, [A, B, C, D])
% will branch to label C.
-
- %
- % function call/return
- %
+ % Function call/return.
; call(
- mlds__func_signature, % signature of the func
- mlds__rval, % the function to call
- maybe(mlds__rval), % for method calls, this field
- % specifies the `this' object
- list(mlds__rval), % ordinary function arguments
- list(mlds__lval), % places to store the
- % function return value(s)
- call_kind % indicates whether this
- % call is a tail call
+ mlds__func_signature, % Signature of the function.
+ mlds__rval, % The function to call.
+ maybe(mlds__rval), % For method calls, this field
+ % specifies the `this' object.
+ list(mlds__rval), % Ordinary function arguments.
+ list(mlds__lval), % Places to store the function return
+ % value(s).
+ call_kind % Indicates whether this call is a
+ % tail call.
)
; return(list(mlds__rval)) % Some targets will not support
- % returning more than one value
+ % returning more than one value.
- %
- % commits (a specialized form of exception handling)
- %
+ % Commits (a specialized form of exception handling).
+ ; try_commit(mlds__lval, mlds__statement, mlds__statement)
+ ; do_commit(mlds__rval)
% try_commit(Ref, GoalToTry, CommitHandlerGoal):
% Execute GoalToTry. If GoalToTry exits via a
% `commit(Ref)' instruction, then execute
@@ -1042,66 +1036,51 @@
% statement for Ref, and branch to the CommitHandlerGoal
% that was specified in that try_commit instruction.
%
- % For both try_commit and do_commit instructions,
- % Ref should be the name of a local variable of type
- % mlds__commit_type. (This variable can be used by
- % the back-end's implementation of do_commit and
- % try_commit to store information needed to unwind
- % the stack.) There should be exactly
- % one try_commit instruction for each Ref.
- % do_commit(Ref) instructions should only be used
- % in goals called from the GoalToTry goal in the
- % try_commit instruction with the same Ref.
- %
- % The C and GCC back-ends require each try_commit
- % to be put in its own nested function, to avoid
- % problems with setjmp() and local vars not declared
- % volatile. They also require each do_commit
- % to be put in its own function -- this is needed when
- % using __builtin_setjmp()/__builtin_longjmp() to
- % ensure that the call to __builtin_longjmp() is
- % not in the same function as the call to
- % __builtin_setjmp().
- %
- ; try_commit(mlds__lval, mlds__statement, mlds__statement)
- ; do_commit(mlds__rval)
+ % For both try_commit and do_commit instructions, Ref should be
+ % the name of a local variable of type mlds__commit_type.
+ % (This variable can be used by the back-end's implementation
+ % of do_commit and try_commit to store information needed to unwind
+ % the stack.) There should be exactly one try_commit instruction
+ % for each Ref. do_commit(Ref) instructions should only be used
+ % in goals called from the GoalToTry goal in the try_commit
+ % instruction with the same Ref.
+ %
+ % The C and GCC back-ends require each try_commit to be put in
+ % its own nested function, to avoid problems with setjmp() and
+ % local vars not declared volatile. They also require each
+ % do_commit to be put in its own function -- this is needed when
+ % using __builtin_setjmp()/__builtin_longjmp() to ensure that
+ % the call to __builtin_longjmp() is not in the same function
+ % as the call to __builtin_setjmp().
+ % Exception handling.
%
- % exception handling
- %
-/*********
-XXX Full exception handling support is not yet implemented.
-
% We use C++-style exceptions.
% For C, the back-end can simulate them using setjmp/longjmp.
%
% XXX This is tentative -- the current definition may be
% a bit too specific to C++-style exceptions.
% It might not be a good choice for different target languages.
+ % XXX Full exception handling support is not yet implemented.
- % throw the specified exception
- ; throw(mlds__type, mlds__rval)
+% ; throw(mlds__type, mlds__rval)
+% % Throw the specified exception.
- % rethrow the current exception
- % (only valid inside an exception handler)
- ; rethrow
-
- % Execute the specified statement, and if it throws an exception,
- % and the exception matches any of the exception handlers,
- % then execute the first matching exception handler.
- ; try_catch(
- mlds__statement,
- list(mlds__exception_handler)
- )
-**********/
+% ; rethrow
+% % Rethrow the current exception
+% % (only valid inside an exception handler).
+
+% ; try_catch(
+% mlds__statement,
+% list(mlds__exception_handler)
+% )
+% % Execute the specified statement, and if it throws an exception,
+% % and the exception matches any of the exception handlers,
+% % then execute the first matching exception handler.
- %
- % atomic statements
- %
+ % Atomic statements.
- ; atomic(mlds__atomic_statement)
-
- .
+ ; atomic(mlds__atomic_statement).
%-----------------------------------------------------------------------------%
%
@@ -1121,63 +1100,58 @@
:- type mlds__switch_cases == list(mlds__switch_case).
:- type mlds__switch_case == pair(mlds__case_match_conds, mlds__statement).
- % case_match_conds should be a _non-empty_ list of conditions;
+ % Case_match_conds should be a _non-empty_ list of conditions;
% if _any_ of the conditions match, this case will be selected.
:- type mlds__case_match_conds == list(mlds__case_match_cond).
% A case_match_cond specifies when a switch case will be selected
:- type mlds__case_match_cond
- ---> match_value(mlds__rval) % match_value(Val) matches if
- % the switch value is equal to
- % the specified Val
-
- ; match_range(mlds__rval, mlds__rval). % match_range(Min, Max)
- % matches if the switch value
- % is between Min and Max,
- % inclusive.
- % Note that this should only be
- % used if the target supports
- % it; currently the C back-end
- % supports this only if you're
- % using the GNU C compiler.
+ ---> match_value(mlds__rval)
+ % match_value(Val) matches if the switch value is equal to
+ % the specified Val.
+
+ ; match_range(mlds__rval, mlds__rval).
+ % match_range(Min, Max) matches if the switch value is between
+ % Min and Max, inclusive. Note that this should only be used
+ % if the target supports it; currently the C back-end supports
+ % this only if you're using the GNU C compiler.
% The switch_default specifies what to do if none of the switch
% conditions match.
:- type mlds__switch_default
- ---> default_is_unreachable % The switch is exhaustive,
- % so the default case should
+ ---> default_is_unreachable
+ % The switch is exhaustive, so the default case should
% never be reached.
- ; default_do_nothing % The default action is to
- % just fall through to the
- % statement after the switch.
+ ; default_do_nothing
+ % The default action is to just fall through to the statement
+ % after the switch.
- ; default_case(mlds__statement). % The default is to execute
- % the specified statement.
+ ; default_case(mlds__statement).
+ % % The default is to execute the specified statement.
%-----------------------------------------------------------------------------%
%
% Extra info for labels
-%
:- type mlds__label == string.
:- type mlds__goto_target
---> label(mlds__label) % Branch to the specified label.
+
; break % Branch to just after the end of the
% immediately enclosing loop or switch,
% just like a C/C++/Java `break' statement.
% Not supported by all target languages.
- ; continue. % Branch to the end of the loop body for
- % the immediately enclosing loop,
- % just like a C/C++/Java/C# `continue'
- % statement.
+
+ ; continue. % Branch to the end of the loop body for the
+ % immediately enclosing loop, just like a
+ % C/C++/Java/C# `continue' statement.
% Not supported by all target languages.
%-----------------------------------------------------------------------------%
%
% Extra info for calls
-%
% The `call_kind' type indicates whether a call is a tail call
% and whether the call is know to never return.
@@ -1191,18 +1165,15 @@
% hint and generate code which does not remove the caller's
% stack frame and/or which falls through to the following
% statement.
- %
:- type call_kind
- ---> no_return_call % a call that never returns
+ ---> no_return_call % A call that never returns
% (this is a special case of a tail call)
- ; tail_call % a tail call
- ; ordinary_call % just an ordinary call
- .
+ ; tail_call % A tail call.
+ ; ordinary_call. % Just an ordinary call.
%-----------------------------------------------------------------------------%
%
% Extra info for exception handling
-%
% XXX This is tentative -- the current definition may be
% a bit too specific to C++-style exceptions.
@@ -1210,13 +1181,13 @@
:- type mlds__exception_handler
---> handler(
maybe(mlds__type),
- % if `yes(T)', specifies the type of exceptions to catch
- % if `no', it means catch all exceptions
+ % If `yes(T)', specifies the type of exceptions to catch.
+ % If `no', it means catch all exceptions.
maybe(string)
- % if `yes(Name)', gives the variable name to use for
- % the exception value
- % if `no', then exception value will not be used
+ % If `yes(Name)', gives the variable name to use for the
+ % exception value.
+ % If `no', then exception value will not be used.
).
%-----------------------------------------------------------------------------%
@@ -1234,14 +1205,13 @@
% Assign the value specified by rval to the location
% specified by lval.
- %
- % heap management
- %
+ % Heap management.
; delete_object(mlds__lval)
% Compile time garbage collect (ie explicitly
% deallocate) the memory used by the lval.
+ ; new_object(
% new_object(Target, Tag, Type,
% Size, CtorName, Args, ArgTypes):
% Allocate a memory block of the given size,
@@ -1250,47 +1220,43 @@
% arguments, and put its address in the given lval,
% possibly after tagging the address with a given tag.
% (Some targets might not support tags.)
- ; new_object(
- mlds__lval, % The target to assign the new object's
- % address to.
+
+ % The target to assign the new object's address to.
+ mlds__lval,
+
+ % A (primary) tag to tag the address with before assigning
+ % the result to the target.
maybe(mlds__tag),
- % A (primary) tag to tag the address
- % with before assigning the result to
- % the target.
- bool, % Indicates whether or not there is
- % a secondary tag. If so, it will
- % be stored as the first argument
- % in the argument list (see below).
- mlds__type, % The type of the object being
- % allocated.
+
+ % Indicates whether or not there is a secondary tag. If so,
+ % it will be stored as the first argument in the argument list
+ % (see below).
+ bool,
+
+ % The type of the object being allocated.
+ mlds__type,
+
+ % The amount of memory that needs to be allocated for the new
+ % object, measured in words (NOT bytes!).
maybe(mlds__rval),
- % The amount of memory that needs to
- % be allocated for the new object,
- % measured in words (NOT bytes!).
+
+ % The name of the constructor to invoke.
maybe(ctor_name),
- % The name of the constructor to
- % invoke.
- list(mlds__rval),
+
% The arguments to the constructor.
- list(mlds__type)
- % The types of the arguments to the
- % constructor.
+ list(mlds__rval),
+
+ % The types of the arguments to the constructor.
%
- % Note that for --low-level-data, we box
- % all fields of objects created with
- % new_object, i.e. they are reprsented
- % with type mlds__generic_type.
- % We also do that for some fields
- % even for --high-level-data
- % (e.g. floating point fields for the
- % MLDS->C and MLDS->asm back-ends).
- % In such cases, the type here
- % should be mlds__generic_type;
- % it is the responsibility of the
- % HLDS->MLDS code generator
- % to insert code to box/unbox
+ % Note that for --low-level-data, we box all fields of objects
+ % created with new_object, i.e. they are reprsented with type
+ % mlds__generic_type. We also do that for some fields even
+ % for --high-level-data (e.g. floating point fields for the
+ % MLDS->C and MLDS->asm back-ends). In such cases, the type
+ % here should be mlds__generic_type; it is the responsibility
+ % of the HLDS->MLDS code generator to insert code to box/unbox
% the arguments.
- %
+ list(mlds__type)
)
; gc_check
@@ -1300,12 +1266,11 @@
% with the MLDS->C back-end.
; mark_hp(mlds__lval)
- % Tell the heap sub-system to store a marker
- % (for later use in restore_hp/1 instructions)
- % in the specified lval.
+ % Tell the heap sub-system to store a marker (for later use in
+ % restore_hp/1 instructions) in the specified lval.
%
- % It's OK for the target to treat this as a no-op,
- % and probably that is what most targets will do.
+ % It's OK for the target to treat this as a no-op, and probably
+ % that is what most targets will do.
; restore_hp(mlds__rval)
% The rval must be a marker as returned by mark_hp/1.
@@ -1315,76 +1280,60 @@
% It's OK for the target to treat this as a no-op,
% and probably that is what most targets will do.
- %
- % trail management
- %
+ % Trail management.
; trail_op(trail_op)
- %
- % foreign language interfacing
- %
+ % Foreign language interfacing.
; inline_target_code(target_lang, list(target_code_component))
- % Do whatever is specified by the
- % target_code_components, which can be any piece
- % of code in the specified target language (C,
- % assembler, or whatever) that does not have any
- % non-local flow of control.
- % This is implemented by embedding the target
- % code in the output stream of instructions or
- % statements.
+ % Do whatever is specified by the target_code_components, which
+ % can be any piece of code in the specified target language (C,
+ % assembler, or whatever) that does not have any non-local flow
+ % of control. This is implemented by embedding the target code
+ % in the output stream of instructions or statements.
+
; outline_foreign_proc(
+ % Do whatever is specified by the string, which can be any
+ % piece of code in the specified foreign language (C#,
+ % managed C++, or whatever). This is implemented by calling
+ % an externally defined function, which the backend must
+ % generate the definition for (in some other file perhaps)
+ % and calling it. The lvals are use to generate the appropriate
+ % forwarding code.
+ % XXX We should also store the list of mlds__rvals where
+ % the input values come from.
+
+ % The foreign language this code is written in.
foreign_language,
- % the foreign language this code is
- % written in.
+
list(outline_arg),
+
+ % Where to store return value(s).
list(mlds__lval),
- % where to store return value(s)
+
+ % The user's foreign language code fragment.
string
- % the user's foreign language code
- % fragment
- )
- % Do whatever is specified by the string, which
- % can be any piece of code in the specified
- % foreign language (C#, managed C++, or
- % whatever).
- % This is implemented by calling an externally
- % defined function, which the backend must
- % generate the definition for (in some other
- % file perhaps) and calling it.
- % The lvals are use to generate the appropriate
- % forwarding code.
- % XXX we should also store the list of mlds__rvals
- % where the input values come from, and use
- .
+ ).
% Stores information about each argument to an outline_foreign_proc.
:- type outline_arg
---> in(
- mlds__type,
- % The type of the argument.
- string,
- % The name of the argument in the foreign code.
- mlds__rval
- % The rval which holds the value of this
+ mlds__type, % The type of the argument.
+ string, % The name of the argument in the foreign code.
+ mlds__rval % The rval which holds the value of this
% argument.
)
; out(
- mlds__type,
- % The type of the argument.
- string,
- % The name of the argument in the foreign code.
- mlds__lval
- % The lval where we are to place the result
+ mlds__type, % The type of the argument.
+ string, % The name of the argument in the foreign code.
+ mlds__lval % The lval where we are to place the result
% calculated by the foreign code into.
)
; unused.
- %
% This is just a random selection of possible languages
% that we might want to target...
- %
:- type target_lang
---> lang_C
; lang_GNU_C
@@ -1393,27 +1342,32 @@
; lang_il
; lang_java
; lang_java_asm
- ; lang_java_bytecode
- .
+ ; lang_java_bytecode.
:- type target_code_component
- ---> user_target_code(string, maybe(prog_context),
- target_code_attributes)
- % user_target_code holds C code from
- % the user's `pragma c_code' declaration
- ; raw_target_code(string, target_code_attributes)
- % raw_target_code holds C code that the
- % compiler has generated. To ensure that
- % following `#line' directives work OK,
- % either the string in a raw_target_code must
- % end in `\n' (or `\n' followed by whitespace),
- % or the following target_code_component must be
- % a `name(Name)' component, for which we do not
- % output #line directives.
+ ---> user_target_code(
+ % User_target_code holds C code from the user's
+ % `pragma foreign_proc' declaration.
+
+ string,
+ maybe(prog_context),
+ target_code_attributes
+ )
+ ; raw_target_code(
+ % Raw_target_code holds C code that the compiler has generated.
+ % To ensure that following `#line' directives work OK, either
+ % the string in a raw_target_code must end in `\n' (or `\n'
+ % followed by whitespace), or the following
+ % target_code_component must be a `name(Name)' component,
+ % for which we do not output #line directives.
+
+ string,
+ target_code_attributes
+ )
+
; target_code_input(mlds__rval)
; target_code_output(mlds__lval)
- ; name(mlds__qualified_entity_name)
- .
+ ; name(mlds__qualified_entity_name).
:- type target_code_attributes == list(target_code_attribute).
@@ -1427,18 +1381,13 @@
% `IL' foreign language interface, and is measured in units
% of stack items.
- %
- % constructor id
- %
+ % Constructor id.
:- type ctor_name == mlds__qualified_ctor_id.
:- type mlds__ctor_id ---> ctor_id(mlds__class_name, arity).
-:- type mlds__qualified_ctor_id ==
- mlds__fully_qualified_name(mlds__ctor_id).
+:- type mlds__qualified_ctor_id == mlds__fully_qualified_name(mlds__ctor_id).
- %
- % trail management
- % For documentation, see the corresponding LLDS instructions
- % in llds.m.
+ % Trail management.
+ % For documentation, see the corresponding LLDS instructions in llds.m.
%
:- type trail_op
---> store_ticket(mlds__lval)
@@ -1446,110 +1395,94 @@
; discard_ticket
; prune_ticket
; mark_ticket_stack(mlds__lval)
- ; prune_tickets_to(mlds__rval)
-% ; discard_tickets_to(mlds__rval) % used only by the library
- .
+ ; prune_tickets_to(mlds__rval).
+% ; discard_tickets_to(mlds__rval). % used only by the library
%-----------------------------------------------------------------------------%
- %
- % A field_id represents some data within an object
- %
-
+ % A field_id represents some data within an object.
:- type field_id
- ---> % offset(N) represents the field
- % at offset N Words.
- offset(mlds__rval)
- ; % named_field(Name, CtorType) represents the field
- % with the specified name. The CtorType gives the
- % MLDS type for this particular constructor.
- % The type of the object is given by the PtrType
- % in the field(..) lval; CtorType may either be
- % the same as PtrType, or it may be a pointer to
- % a derived class. In the latter case, the
- % MLDS->target code back-end is responsible
- % for inserting a downcast from PtrType to CtorType
- % before accessing the field.
- named_field(mlds__fully_qualified_name(field_name), mlds__type)
- .
+ ---> offset(mlds__rval)
+ % offset(N) represents the field at offset N Words.
+
+ ; named_field(mlds__fully_qualified_name(field_name), mlds__type).
+ % named_field(Name, CtorType) represents the field with the
+ % specified name. The CtorType gives the MLDS type for this
+ % particular constructor. The type of the object is given by
+ % the PtrType in the field(..) lval; CtorType may either be
+ % the same as PtrType, or it may be a pointer to a derived class.
+ % In the latter case, the MLDS->target code back-end is responsible
+ % for inserting a downcast from PtrType to CtorType before
+ % accessing the field.
:- type field_name == string.
- %
% An mlds__var represents a variable or constant.
- %
:- type mlds__var == mlds__fully_qualified_name(mlds__var_name).
-:- type mlds__var_name --->
- mlds__var_name(string, maybe(int)).
- % var name and perhaps a unique number to be added as a
+:- type mlds__var_name
+ ---> mlds__var_name(string, maybe(int)).
+ % Var name and perhaps a unique number to be added as a
% suffix where necessary.
- %
% An lval represents a data location or variable that can be used
% as the target of an assignment.
- %
:- type mlds__lval
- %
- % values on the heap
- % or fields of a structure
- %
- ---> field(maybe(mlds__tag), mlds__rval, field_id,
- mlds__type, mlds__type)
- % field(Tag, Address, FieldId, FieldType,
- % PtrType)
- % selects a field of a compound term.
- % Address is a tagged pointer to a cell
- % on the heap; the position in the cell,
- % FieldId, is represented either as a field
- % name or a number of words offset. If Tag is
- % yes, the arg gives the value of the tag; if
- % it is no, the tag bits will have to be masked
- % off. The value of the tag should be given if
- % it is known, since this will lead to
- % faster code.
- % The FieldType is the type of the field.
- % The PtrType is the type of the pointer
- % from which we are fetching the field.
- %
- % Note that for --low-level-data, we box
- % all fields of objects created with
- % new_object, i.e. they are reprsented
- % with type mlds__generic_type.
- % We also do that for some fields
- % even for --high-level-data
- % (e.g. floating point fields for the
- % MLDS->C and MLDS->asm back-ends)
- % In such cases,
- % the type here should be mlds__generic_type,
- % not the actual type of the field.
- % If the actual type is different, then it
- % is the HLDS->MLDS code generator's
- % responsibility to insert the necessary
- % code to handle boxing/unboxing.
-
- %
- % values somewhere in memory
- % this is the deference operator (e.g. unary `*' in C)
- %
- ; mem_ref(mlds__rval, mlds__type)
- % The rval should have originally come
- % from a mem_addr rval.
- % The type is the type of the value being
- % dereferenced
-
- %
- % variables
- % these may be local or they may come from some enclosing scope
- % the variable name should be fully qualified
- ; var(mlds__var, mlds__type)
+ % Values on the heap or fields of a structure.
+
+ ---> field(
+ % field(Tag, Address, FieldId, FieldType, PtrType):
+ % Selects a field of a compound term.
+
+ % Address is a tagged pointer to a cell on the heap.
+ % The position in the cell, FieldId, is represented either
+ % as a field name or a number of words offset. If Tag is yes,
+ % the arg gives the value of the tag; if it is no, the tag bits
+ % will have to be masked off. The value of the tag should be
+ % given if it is known, since this will lead to faster code.
+ % The FieldType is the type of the field. The PtrType is the
+ % type of the pointer from which we are fetching the field.
+ %
+ % Note that for --low-level-data, we box all fields of objects
+ % created with new_object, i.e. they are reprsented with type
+ % mlds__generic_type. We also do that for some fields even
+ % for --high-level-data (e.g. floating point fields for the
+ % MLDS->C and MLDS->asm back-ends). In such cases, the type
+ % here should be mlds__generic_type, not the actual type of
+ % the field. If the actual type is different, then it is the
+ % HLDS->MLDS code generator's responsibility to insert the
+ % necessary code to handle boxing/unboxing.
+
+ field_tag :: maybe(mlds__tag),
+ field_addr :: mlds__rval,
+ field_field_id :: field_id,
+ field_type :: mlds__type,
+ field_ptr_typ :: mlds__type
+ )
+
+ % Values somewhere in memory.
+ % This is the deference operator (e.g. unary `*' in C).
+
+ ; mem_ref(
+ % The rval should have originally come from a mem_addr rval.
+ % The type is the type of the value being dereferenced
+
+ mlds__rval,
+ mlds__type
+ )
- .
+ % Variables.
+ % These may be local or they may come from some enclosing scope
+ % the variable name should be fully qualified.
+
+ ; var(
+ mlds__var,
+ mlds__type
+ ).
%-----------------------------------------------------------------------------%
%
% Expressions
-%
% An rval is an expression that represents a value.
:- type mlds__rval
@@ -1574,30 +1507,25 @@
% The address of a variable, etc.
; self(mlds__type).
- % The equivalent of the `this' pointer in C++ with the
- % type of the object. Note that this rval is valid iff
- % we are targetting an object oriented backend and we
- % are in an instance method (procedures which have the
- % per_instance flag set).
+ % The equivalent of the `this' pointer in C++ with the type of the
+ % object. Note that this rval is valid iff we are targeting an
+ % object oriented backend and we are in an instance method
+ % (procedures which have the per_instance flag set).
:- type mlds__unary_op
- % box(MLDSType)
- % convert from MLDSType to mlds__generic_type,
- % by boxing if necessary, or just casting if not
---> box(mlds__type)
+ % box(MLDSType); convert from MLDSType to mlds__generic_type,
+ % by boxing if necessary, or just casting if not.
- % unbox(MLDSType)
- % convert from mlds__generic_type to MLDSType,
- % applying the inverse transformation to box/1,
- % i.e. unboxing if boxing was necessary,
- % and just casting otherwise.
; unbox(mlds__type)
+ % unbox(MLDSType): convert from mlds__generic_type to MLDSType,
+ % applying the inverse transformation to box/1, i.e. unboxing
+ % if boxing was necessary, and just casting otherwise.
- % cast(MLDSType):
- % Coerce the type of the rval to be MLDSType.
- % XXX it might be worthwhile adding the
- % type that we cast from.
; cast(mlds__type)
+ % cast(MLDSType): Coerce the type of the rval to be MLDSType.
+ % XXX It might be worthwhile adding the type that we cast from.
+
; std_unop(builtin_ops__unary_op).
:- type mlds__rval_const
@@ -1606,67 +1534,75 @@
; int_const(int)
; float_const(float)
; string_const(string)
- % A multi_string_const is a string containing
- % embedded NULs, whose real length is given
- % by the integer, and not the location of the
- % first null character.
; multi_string_const(int, string)
+ % A multi_string_const is a string containing embedded NULs,
+ % whose real length is given by the integer, and not the location
+ % of the first null character.
+
; code_addr_const(mlds__code_addr)
; data_addr_const(mlds__data_addr)
- % A null value, of the given type.
- % Usually the type will be a pointer (mlds__ptr_type)
- % but it could also be string or a func_type.
- % (Null is not a valid value of type string
- % or func_type, but null values of those types
- % may be useful as placeholders in cases where the
- % value will never be used.)
- ; null(mlds__type).
+ ; null(mlds__type).
+ % A null value, of the given type. Usually the type will be a
+ % pointer (mlds__ptr_type) but it could also be string or a
+ % func_type. (Null is not a valid value of type string or
+ % func_type, but null values of those types may be useful as
+ % placeholders in cases where the value will never be used.)
:- type mlds__code_addr
- ---> proc(mlds__qualified_proc_label, mlds__func_signature)
- ; internal(mlds__qualified_proc_label, mlds__func_sequence_num,
- mlds__func_signature).
+ ---> proc(
+ mlds__qualified_proc_label,
+ mlds__func_signature
+ )
+ ; internal(
+ mlds__qualified_proc_label,
+ mlds__func_sequence_num,
+ mlds__func_signature
+ ).
:- type mlds__data_addr
- ---> data_addr(mlds_module_name, mlds__data_name).
- % module name; which var
+ ---> data_addr(
+ mlds_module_name, % The name of the module module.
+ mlds__data_name % The id of the variable inside the module.
+ ).
:- type mlds__data == mlds__fully_qualified_name(mlds__data_name).
:- type mlds__data_name
---> var(mlds__var_name)
- % ordinary variables
+ % Ordinary variables.
+
; common(int)
- % Compiler-introduced constants representing
- % global constants. These are called "common"
- % because they may be common sub-expressions.
- %
+ % Compiler-introduced constants representing global constants.
+ % These are called "common" because they may be common
+ % subexpressions.
+
% Stuff for handling polymorphism/RTTI and type classes.
- %
+
; rtti(rtti_id)
- %
+
% Stuff for handling debugging and accurate garbage collection.
% (Those features are not yet implemented for the MLDS back-end,
% so these data_names are not yet used.)
- %
+
; module_layout
% Layout information for the current module.
+
; proc_layout(mlds__proc_label)
% Layout structure for the given procedure.
+
; internal_layout(mlds__proc_label, mlds__func_sequence_num)
% Layout structure for the given internal MLDS func.
- %
+
% Stuff for tabling
- %
+
; tabling_pointer(mlds__proc_label).
- % A variable that contains a pointer that points to
- % the table used to implement memoization, loopcheck
- % or minimal model semantics for the given procedure.
+ % A variable that contains a pointer that points to the table
+ % used to implement memoization, loopcheck or minimal model
+ % semantics for the given procedure.
%-----------------------------------------------------------------------------%
-%
% Note: the types `tag' and `reset_trail_reason' here are all
% defined exactly the same as the ones in llds.m. The definitions are
% duplicated here because we don't want mlds.m to depend on llds.m.
@@ -1674,7 +1610,6 @@
% imported by both mlds.m and llds.m, but these definitions are small enough
% and simple enough that I don't think it is worth creating a new module
% just for them.)
-%
% A tag should be a small non-negative integer.
:- type tag == int.
@@ -1685,8 +1620,7 @@
; commit
; solve
; exception
- ; gc
- .
+ ; gc.
%-----------------------------------------------------------------------------%
@@ -1710,14 +1644,14 @@
:- type mlds__pred_label
---> pred(
pred_or_func, % predicate/function
+ maybe(mercury_module_name),
% The declaring module,
% if different to the defining module
- maybe(mercury_module_name),
- string, % name
- arity, % arity
- code_model, % code model
- bool % function without return value
- % (i.e. non-default mode)
+ string, % Name.
+ arity, % Arity.
+ code_model, % Code model.
+ bool % Function without return value
+ % (i.e. non-default mode).
)
; special_pred(
@@ -1726,18 +1660,20 @@
% The module declaring the type,
% if this is different to module defining
% the special_pred.
- string, % the type name
- arity % the type arity
+ string, % The type name.
+ arity % The type arity.
).
%-----------------------------------------------------------------------------%
% Invert the case of the first letter of the string.
% This is used for the Java back-end.
+ %
:- func flip_initial_case(string) = string.
% Invert the case of the first letter of the last component of
% a (possibly) qualified name. This is used for the Java back-end.
+ %
:- func flip_initial_case_of_final_part(sym_name) = sym_name.
%-----------------------------------------------------------------------------%
@@ -1767,7 +1703,8 @@
% Currently mlds__contexts just contain a prog_context.
-:- type mlds__context ---> mlds__context(prog_context).
+:- type mlds__context
+ ---> mlds__context(prog_context).
mlds__make_context(Context) = mlds__context(Context).
@@ -1796,8 +1733,7 @@
module_info_get_type_table(ModuleInfo, Types),
map__search(Types, TypeCtor, TypeDefn),
hlds_data__get_type_defn_body(TypeDefn, Body),
- Body = foreign_type(foreign_type_body(MaybeIL, MaybeC,
- MaybeJava))
+ Body = foreign_type(foreign_type_body(MaybeIL, MaybeC, MaybeJava))
->
module_info_get_globals(ModuleInfo, Globals),
globals__get_target(Globals, Target),
@@ -1805,13 +1741,11 @@
Target = c,
(
MaybeC = yes(Data),
- Data = foreign_type_lang_data(CForeignType,
- _, _),
+ Data = foreign_type_lang_data(CForeignType, _, _),
ForeignType = c(CForeignType)
;
MaybeC = no,
- % This is checked by check_foreign_type
- % in make_hlds.
+ % This is checked by check_foreign_type in make_hlds.
unexpected(this_file,
"mercury_type_to_mlds_type: No C foreign type")
)
@@ -1819,13 +1753,11 @@
Target = il,
(
MaybeIL = yes(Data),
- Data = foreign_type_lang_data(ILForeignType,
- _, _),
+ Data = foreign_type_lang_data(ILForeignType, _, _),
ForeignType = il(ILForeignType)
;
MaybeIL = no,
- % This is checked by check_foreign_type
- % in make_hlds.
+ % This is checked by check_foreign_type in make_hlds.
unexpected(this_file,
"mercury_type_to_mlds_type: No IL foreign type")
)
@@ -1833,29 +1765,24 @@
Target = java,
(
MaybeJava = yes(Data),
- Data = foreign_type_lang_data(JavaForeignType,
- _, _),
+ Data = foreign_type_lang_data(JavaForeignType, _, _),
ForeignType = java(JavaForeignType)
;
MaybeJava = no,
- % This is checked by check_foreign_type
- % in make_hlds.
+ % This is checked by check_foreign_type in make_hlds.
unexpected(this_file,
- "mercury_type_to_mlds_type: " ++
- "No Java foreign type")
+ "mercury_type_to_mlds_type: no Java foreign type")
)
;
Target = asm,
(
MaybeC = yes(Data),
- Data = foreign_type_lang_data(CForeignType,
- _, _),
+ Data = foreign_type_lang_data(CForeignType, _, _),
ForeignType = c(CForeignType)
;
MaybeC = no,
- % XXX This ought to be checked by the
- % front-end, e.g. check_foreign_type
- % in make_hlds.
+ % XXX This ought to be checked by the front-end, e.g.
+ % check_foreign_type in make_hlds.
sorry(this_file,
"mercury_type_to_mlds_type: No C foreign type")
)
@@ -1922,10 +1849,8 @@
mlds__append_class_qualifier(name(Package, Module), QualKind, Globals,
ClassName, ClassArity) =
name(Package, qualified(AdjustedModule, ClassQualifier)) :-
- %
- % For the Java back-end, we flip the initial case of an type
- % qualifiers, in order to match the usual Java conventions.
- %
+ % For the Java back-end, we flip the initial case of an type qualifiers,
+ % in order to match the usual Java conventions.
(
globals__get_target(Globals, CompilationTarget),
CompilationTarget = java,
@@ -1935,8 +1860,7 @@
;
AdjustedModule = Module
),
- string__format("%s_%d", [s(ClassName), i(ClassArity)],
- ClassQualifier).
+ string__format("%s_%d", [s(ClassName), i(ClassArity)], ClassQualifier).
mlds__append_wrapper_class(Name) = mlds__append_name(Name, wrapper_class_name).
@@ -1967,13 +1891,10 @@
%-----------------------------------------------------------------------------%
-%
-% We represent the set of declaration flags as a bunch of bit-fields packed
-% into a single int.
-%
+ % We represent the set of declaration flags as a bunch of bit-fields packed
+ % into a single int.
:- type mlds__decl_flags == int.
-%
% Here we define which bits are used to store each bitfield.
%
% It would be nicer to use a language builtin, e.g. index/2, for these.
@@ -1991,7 +1912,6 @@
%
% On the other hand, doing it manually may be more efficient than either
% of those two approaches.
-%
:- func access_bits(access) = int.
:- mode access_bits(in) = out is det.
@@ -2079,7 +1999,6 @@
promise_det(Pred) = X :-
(if Pred(X0) then X = X0 else error("promise_det failed")).
-
%
% Here we define the functions to set a member of the set.
%
@@ -2114,6 +2033,7 @@
%-----------------------------------------------------------------------------%
:- func this_file = string.
+
this_file = "mlds.m".
%-----------------------------------------------------------------------------%
Index: compiler/mode_constraints.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_constraints.m,v
retrieving revision 1.14
diff -u -b -r1.14 mode_constraints.m
--- compiler/mode_constraints.m 30 Sep 2005 08:08:27 -0000 1.14
+++ compiler/mode_constraints.m 11 Oct 2005 15:16:55 -0000
@@ -20,7 +20,7 @@
:- import_module hlds__hlds_module.
:- import_module io.
-:- pred mode_constraints__process_module(module_info::in, module_info::out,
+:- pred process_module(module_info::in, module_info::out,
io::di, io::uo) is det.
:- implementation.
@@ -88,7 +88,7 @@
func 'ho_modes :='(T, ho_modes) = T
].
-mode_constraints__process_module(!ModuleInfo, !IO) :-
+process_module(!ModuleInfo, !IO) :-
module_info_predids(!.ModuleInfo, PredIds),
globals__io_lookup_bool_option(simple_mode_constraints, Simple, !IO),
globals__io_lookup_bool_option(prop_mode_constraints, New, !IO),
@@ -99,7 +99,7 @@
% Stage 1: Process SCCs bottom-up to determine variable producers.
(
New = no,
- list__foldl3(mode_constraints__process_scc(Simple), SCCs,
+ list__foldl3(process_scc(Simple), SCCs,
!ModuleInfo, map__init, PredConstraintMap, !IO),
% Stage 2: Process SCCs top-down to determine execution order of
@@ -145,11 +145,11 @@
)
).
-:- pred mode_constraints__process_scc(bool::in, list(pred_id)::in,
+:- pred process_scc(bool::in, list(pred_id)::in,
module_info::in, module_info::out,
pred_constraint_map::in, pred_constraint_map::out, io::di, io::uo) is det.
-mode_constraints__process_scc(Simple, SCC, !ModuleInfo, !PredConstraintMap,
+process_scc(Simple, SCC, !ModuleInfo, !PredConstraintMap,
!IO) :-
some [!ModeConstraint, !ModeConstraintInfo] (
!:ModeConstraint = one,
@@ -158,12 +158,12 @@
!ModeConstraintInfo),
save_threshold(Threshold, !ModeConstraintInfo),
- mode_constraints__process_scc_pass_1(SCC, SCC, !ModuleInfo,
+ process_scc_pass_1(SCC, SCC, !ModuleInfo,
!ModeConstraint, !ModeConstraintInfo, !IO),
!:ModeConstraint = restrict_threshold(Threshold, !.ModeConstraint),
!:ModeConstraint = ensure_normalised(!.ModeConstraint),
- mode_constraints__process_scc_pass_2(SCC, !.ModeConstraint,
+ process_scc_pass_2(SCC, !.ModeConstraint,
!.ModeConstraintInfo, !ModuleInfo, !IO),
Insert = (pred(PredId::in, PCM0::in, PCM::out) is det :-
@@ -446,40 +446,40 @@
Cases0, Cases, !RInfo),
Occurring = Occurring0 `set__union` Occurring1.
-:- pred mode_constraints__process_scc_pass_1(list(pred_id)::in,
+:- pred process_scc_pass_1(list(pred_id)::in,
list(pred_id)::in, module_info::in,
module_info::out, mode_constraint::in, mode_constraint::out,
mode_constraint_info::in, mode_constraint_info::out,
io::di, io::uo) is det.
-mode_constraints__process_scc_pass_1([], _, !ModuleInfo,
+process_scc_pass_1([], _, !ModuleInfo,
!ModeConstraint, !ModeConstraintInfo, !IO).
-mode_constraints__process_scc_pass_1([PredId | PredIds], SCC,
+process_scc_pass_1([PredId | PredIds], SCC,
!ModuleInfo, !ModeConstraint, !ModeConstraintInfo, !IO) :-
!:ModeConstraintInfo = !.ModeConstraintInfo ^ pred_id := PredId,
- mode_constraints__process_pred(PredId, SCC, !ModuleInfo,
+ process_pred(PredId, SCC, !ModuleInfo,
!ModeConstraint, !ModeConstraintInfo, !IO),
- mode_constraints__process_scc_pass_1(PredIds, SCC, !ModuleInfo,
+ process_scc_pass_1(PredIds, SCC, !ModuleInfo,
!ModeConstraint, !ModeConstraintInfo, !IO).
-:- pred mode_constraints__process_scc_pass_2(list(pred_id)::in,
+:- pred process_scc_pass_2(list(pred_id)::in,
mode_constraint::in, mode_constraint_info::in, module_info::in,
module_info::out, io::di, io::uo) is det.
-mode_constraints__process_scc_pass_2([], _, _, !ModuleInfo, !IO).
-mode_constraints__process_scc_pass_2([PredId | PredIds], ModeConstraint,
+process_scc_pass_2([], _, _, !ModuleInfo, !IO).
+process_scc_pass_2([PredId | PredIds], ModeConstraint,
ModeConstraintInfo, !ModuleInfo, !IO) :-
- mode_constraints__process_pred_2(PredId, ModeConstraint,
+ process_pred_2(PredId, ModeConstraint,
ModeConstraintInfo ^ pred_id := PredId, !ModuleInfo, !IO),
- mode_constraints__process_scc_pass_2(PredIds, ModeConstraint,
+ process_scc_pass_2(PredIds, ModeConstraint,
ModeConstraintInfo, !ModuleInfo, !IO).
-:- pred mode_constraints__process_pred(pred_id::in, list(pred_id)::in,
+:- pred process_pred(pred_id::in, list(pred_id)::in,
module_info::in, module_info::out, mode_constraint::in,
mode_constraint::out, mode_constraint_info::in,
mode_constraint_info::out, io::di, io::uo) is det.
-mode_constraints__process_pred(PredId, SCC, !ModuleInfo, !ModeConstraint,
+process_pred(PredId, SCC, !ModuleInfo, !ModeConstraint,
!ModeConstraintInfo, !IO) :-
module_info_pred_info(!.ModuleInfo, PredId, PredInfo0),
write_pred_progress_message("% Calculating mode constraints for ",
@@ -499,7 +499,7 @@
;
ModeDeclInfo0 = mode_decl_info(!.ModeConstraintInfo, HOModes0),
map__map_foldl2(
- mode_constraints__mode_decl_to_constraint(!.ModuleInfo,
+ mode_decl_to_constraint(!.ModuleInfo,
InstGraph, HeadVars, PredInfo0),
ProcTable0, ProcTable,
zero, DeclConstraint, ModeDeclInfo0, ModeDeclInfo),
@@ -521,8 +521,7 @@
( pred_info_is_imported(PredInfo1) ->
PredInfo = PredInfo1
;
-
- mode_constraints__process_clauses_info(!.ModuleInfo, SCC,
+ process_clauses_info(!.ModuleInfo, SCC,
ClausesInfo0, ClausesInfo, InstGraph, HOModes,
!ModeConstraint, !ModeConstraintInfo, !IO),
pred_info_set_clauses_info(ClausesInfo,
@@ -530,11 +529,11 @@
),
module_info_set_pred_info(PredId, PredInfo, !ModuleInfo).
-:- pred mode_constraints__process_pred_2(pred_id::in, mode_constraint::in,
+:- pred process_pred_2(pred_id::in, mode_constraint::in,
mode_constraint_info::in, module_info::in, module_info::out,
io::di, io::uo) is det.
-mode_constraints__process_pred_2(PredId, ModeConstraint, ModeConstraintInfo0,
+process_pred_2(PredId, ModeConstraint, ModeConstraintInfo0,
!ModuleInfo, !IO) :-
module_info_pred_info(!.ModuleInfo, PredId, PredInfo0),
@@ -672,15 +671,15 @@
% Convert a procedure's arg_modes to a constraint.
%
-:- pred mode_constraints__mode_decl_to_constraint(module_info::in,
+:- pred mode_decl_to_constraint(module_info::in,
inst_graph::in, list(prog_var)::in, pred_info::in, proc_id::in,
proc_info::in, proc_info::out,
mode_constraint::in, mode_constraint::out,
mode_decl_info::in, mode_decl_info::out) is det.
-mode_constraints__mode_decl_to_constraint(ModuleInfo, InstGraph, HeadVars,
+mode_decl_to_constraint(ModuleInfo, InstGraph, HeadVars,
_PredInfo, _ProcId, !ProcInfo, !Constraint, !Info) :-
- mode_constraints__process_mode_decl_for_proc(ModuleInfo,
+ process_mode_decl_for_proc(ModuleInfo,
InstGraph, HeadVars,
false_var(initial), true_var(initial), yes,
false_var(final), true_var(final), no,
@@ -696,7 +695,7 @@
!:Constraint = !.Constraint + DeclConstraint,
proc_info_set_head_modes_constraint(DeclConstraint, !ProcInfo).
-:- pred mode_constraints__process_mode_decl_for_proc(module_info::in,
+:- pred process_mode_decl_for_proc(module_info::in,
inst_graph::in, list(prog_var)::in,
constrain_var::in(constrain_var), constrain_var::in(constrain_var),
bool::in,
@@ -705,35 +704,32 @@
proc_info::in, mode_constraint::in, mode_constraint::out,
mode_decl_info::in, mode_decl_info::out) is det.
-mode_constraints__process_mode_decl_for_proc(ModuleInfo, InstGraph, HeadVars,
- InitialFree, InitialBound, InitialHO,
- FinalFree, FinalBound, FinalHO,
+process_mode_decl_for_proc(ModuleInfo, InstGraph, HeadVars,
+ InitialFree, InitialBound, InitialHO, FinalFree, FinalBound, FinalHO,
ProcInfo, !Constraint, !MDI) :-
% proc_info_declared_argmodes(ProcInfo, ArgModes),
proc_info_argmodes(ProcInfo, ArgModes),
- mode_constraints__process_mode_decl(ModuleInfo, InstGraph, HeadVars,
- InitialFree, InitialBound, InitialHO,
- FinalFree, FinalBound, FinalHO,
+ process_mode_decl(ModuleInfo, InstGraph, HeadVars,
+ InitialFree, InitialBound, InitialHO, FinalFree, FinalBound, FinalHO,
ArgModes, !Constraint, !MDI).
-:- pred mode_constraints__process_mode_decl(module_info::in,
+:- pred process_mode_decl(module_info::in,
inst_graph::in, list(prog_var)::in, constrain_var::in(constrain_var),
constrain_var::in(constrain_var), bool::in,
constrain_var::in(constrain_var), constrain_var::in(constrain_var),
bool::in, list(mode)::in, mode_constraint::in, mode_constraint::out,
mode_decl_info::in, mode_decl_info::out) is det.
-mode_constraints__process_mode_decl(ModuleInfo, InstGraph, HeadVars,
+process_mode_decl(ModuleInfo, InstGraph, HeadVars,
InitialFree, InitialBound, InitialHO,
FinalFree, FinalBound, FinalHO, ArgModes, !Constraint, !MDI) :-
assoc_list__from_corresponding_lists(HeadVars, ArgModes, VarModes),
- list__foldl2(mode_constraints__process_arg_modes(ModuleInfo, InstGraph,
- InitialFree, InitialBound, InitialHO,
- FinalFree, FinalBound, FinalHO),
+ list__foldl2(process_arg_modes(ModuleInfo, InstGraph,
+ InitialFree, InitialBound, InitialHO, FinalFree, FinalBound, FinalHO),
VarModes, one, NewConstraint, !MDI),
!:Constraint = !.Constraint + NewConstraint.
-:- pred mode_constraints__process_arg_modes(module_info::in, inst_graph::in,
+:- pred process_arg_modes(module_info::in, inst_graph::in,
constrain_var::in(constrain_var), constrain_var::in(constrain_var),
bool::in,
constrain_var::in(constrain_var), constrain_var::in(constrain_var),
@@ -742,15 +738,15 @@
mode_constraint::in, mode_constraint::out,
mode_decl_info::in, mode_decl_info::out) is det.
-mode_constraints__process_arg_modes(ModuleInfo, InstGraph,
+process_arg_modes(ModuleInfo, InstGraph,
InitialFree, InitialBound, InitialHO,
FinalFree, FinalBound, FinalHO,
Var - Mode, !Constraint, !MDI) :-
mode_get_insts(ModuleInfo, Mode, InitialInst, FinalInst),
- mode_constraints__process_inst(ModuleInfo, InstGraph,
+ process_inst(ModuleInfo, InstGraph,
InitialFree, InitialBound, InitialHO, InitialInst,
set__init, Var, !Constraint, !MDI),
- mode_constraints__process_inst(ModuleInfo, InstGraph,
+ process_inst(ModuleInfo, InstGraph,
FinalFree, FinalBound, FinalHO, FinalInst,
set__init, Var, !Constraint, !MDI).
@@ -814,34 +810,34 @@
mode_constraint_info, mode_constraint_info).
:- inst constrain_var == (pred(in, in, out, in, out) is det).
-:- pred mode_constraints__process_inst(module_info::in, inst_graph::in,
+:- pred process_inst(module_info::in, inst_graph::in,
constrain_var::in(constrain_var), constrain_var::in(constrain_var),
bool::in, (inst)::in, set(prog_var)::in, prog_var::in,
mode_constraint::in, mode_constraint::out,
mode_decl_info::in, mode_decl_info::out) is det.
-mode_constraints__process_inst(ModuleInfo, InstGraph, Free, Bound, DoHO, Inst,
+process_inst(ModuleInfo, InstGraph, Free, Bound, DoHO, Inst,
Seen, Var, !Constraint, !MDI) :-
( Var `set__member` Seen ->
true
;
( Inst = defined_inst(InstName) ->
inst_lookup(ModuleInfo, InstName, Inst1),
- mode_constraints__process_inst(ModuleInfo, InstGraph,
+ process_inst(ModuleInfo, InstGraph,
Free, Bound, DoHO, Inst1, Seen, Var, !Constraint, !MDI)
;
- mode_constraints__do_process_inst(ModuleInfo, InstGraph,
+ do_process_inst(ModuleInfo, InstGraph,
Free, Bound, DoHO, Inst, Seen, Var, !Constraint, !MDI)
)
).
-:- pred mode_constraints__do_process_inst(module_info::in, inst_graph::in,
+:- pred do_process_inst(module_info::in, inst_graph::in,
constrain_var::in(constrain_var), constrain_var::in(constrain_var),
bool::in, (inst)::in, set(prog_var)::in, prog_var::in,
mode_constraint::in, mode_constraint::out,
mode_decl_info::in, mode_decl_info::out) is det.
-mode_constraints__do_process_inst(ModuleInfo, InstGraph, Free, Bound, DoHO,
+do_process_inst(ModuleInfo, InstGraph, Free, Bound, DoHO,
Inst, Seen, Var, !Constraint, !MDI) :-
update_mc_info((pred(C::out, S0::in, S::out) is det :-
(
@@ -872,7 +868,7 @@
Insts, VarInsts),
list__foldl2((pred((V - I)::in, C1::in, C2::out,
T0::in, T::out) is det :-
- mode_constraints__process_inst(ModuleInfo, InstGraph,
+ process_inst(ModuleInfo, InstGraph,
Free, Bound, DoHO, I, Seen `set__insert` Var,
V, C1, C2, T0, T)
), VarInsts, C0, C, S0, S)
@@ -882,11 +878,10 @@
)
;
list__foldl2(
- mode_constraints__process_inst(ModuleInfo, InstGraph,
+ process_inst(ModuleInfo, InstGraph,
Free, Bound, DoHO, Inst, Seen `set__insert` Var),
Vs, C0, C, S0, S)
)), Functors, !Constraint, !MDI),
-
(
DoHO = yes,
Inst = ground(_, higher_order(pred_inst_info(_, ArgModes, _)))
@@ -899,13 +894,13 @@
true
).
-:- pred mode_constraints__process_clauses_info(module_info::in,
+:- pred process_clauses_info(module_info::in,
list(pred_id)::in, clauses_info::in, clauses_info::out, inst_graph::in,
ho_modes::in, mode_constraint::in, mode_constraint::out,
mode_constraint_info::in, mode_constraint_info::out,
io::di, io::uo) is det.
-mode_constraints__process_clauses_info(ModuleInfo, SCC, !ClausesInfo,
+process_clauses_info(ModuleInfo, SCC, !ClausesInfo,
InstGraph, HOModes0, !Constraint, !ConstraintInfo, !IO) :-
clauses_info_varset(!.ClausesInfo, VarSet0),
globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
@@ -1157,7 +1152,7 @@
map__values(ProcTable, ProcInfos),
update_md_info((pred(C::out, S0::in, S::out) is det :-
list__foldl2(
- mode_constraints__process_mode_decl_for_proc(ModuleInfo,
+ process_mode_decl_for_proc(ModuleInfo,
InstGraph, Args, ignore, call_in(GoalPath), no,
false_var(goal_path(GoalPath)), call_out(GoalPath),
yes),
@@ -1527,7 +1522,7 @@
ArgModes = list__duplicate(length(NonLocals), in_mode) ++ Modes,
LambdaHeadVars = NonLocals ++ LambdaVars,
ModuleInfo = !.GCInfo ^ module_info,
- update_md_info(mode_constraints__process_mode_decl(ModuleInfo,
+ update_md_info(process_mode_decl(ModuleInfo,
InstGraph, LambdaHeadVars, false_var(initial),
true_var(initial), yes, false_var(final), true_var(final), no,
ArgModes, zero), DeclConstraint, !GCInfo),
@@ -1608,7 +1603,7 @@
(pred((GoalPath - Args)::in, C0::in, C::out,
in, out) is det -->
list__foldl2(
- mode_constraints__process_mode_decl(
+ process_mode_decl(
ModuleInfo, InstGraph, Args, ignore,
call_in(GoalPath), no,
false_var(goal_path(GoalPath)),
@@ -1696,7 +1691,7 @@
% the rest of their SCC since the mode declaration can be used in any
% calls to them. Such predicates should be processed last to take
% advantage of mode info inferred from other predicates.
- extract_mode_decl_preds(ModuleInfo, [], SCCs0, SCCs1),
+ extract_mode_decl_preds(ModuleInfo, SCCs0, [], SCCs1),
% We add imported preds to the end of the SCC list, one SCC per pred.
% This allows a constraint to be created for each imported pred
@@ -1706,22 +1701,24 @@
:- pred extract_mode_decl_preds(module_info::in, sccs::in, sccs::in, sccs::out)
is det.
-extract_mode_decl_preds(_ModuleInfo, DeclaredPreds, [], DeclaredPreds).
-extract_mode_decl_preds(ModuleInfo, DeclaredPreds0, [SCC0 | SCCs0], SCCs) :-
+extract_mode_decl_preds(_ModuleInfo, [], !DeclaredPreds).
+extract_mode_decl_preds(ModuleInfo, [SCC0 | SCCs0], !DeclaredPreds) :-
list__filter(pred_has_mode_decl(ModuleInfo), SCC0, Declared, SCC),
- ( Declared = [] ->
- DeclaredPreds = DeclaredPreds0
+ (
+ Declared = []
;
+ Declared = [_ | _],
list__foldl(
(pred(Pred::in, Preds0::in, Preds::out) is det :-
Preds = [[Pred] | Preds0]
- ), Declared, DeclaredPreds0, DeclaredPreds)
+ ), Declared, !DeclaredPreds)
),
- extract_mode_decl_preds(ModuleInfo, DeclaredPreds, SCCs0, SCCs1),
- ( SCC = [] ->
- SCCs = SCCs1
+ extract_mode_decl_preds(ModuleInfo, SCCs0, !DeclaredPreds),
+ (
+ SCC = []
;
- SCCs = [SCC | SCCs1]
+ SCC = [_ | _],
+ !:DeclaredPreds = [SCC | !.DeclaredPreds]
).
:- pred pred_has_mode_decl(module_info::in, pred_id::in) is semidet.
@@ -1751,8 +1748,7 @@
cons_id_in_bound_insts(ConsId, BIs, Insts)
).
-:- pred equivalent_cons_ids(cons_id, cons_id).
-:- mode equivalent_cons_ids(in, in) is semidet.
+:- pred equivalent_cons_ids(cons_id::in, cons_id::in) is semidet.
equivalent_cons_ids(ConsIdA, ConsIdB) :-
(
@@ -1765,8 +1761,7 @@
ConsIdA = ConsIdB
).
-:- pred equivalent_sym_names(sym_name, sym_name).
-:- mode equivalent_sym_names(in, in) is semidet.
+:- pred equivalent_sym_names(sym_name::in, sym_name::in) is semidet.
equivalent_sym_names(unqualified(S), unqualified(S)).
equivalent_sym_names(qualified(_, S), unqualified(S)).
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list