[m-rev.] diff: removing more bad dependencies
Zoltan Somogyi
zs at cs.mu.OZ.AU
Sun Mar 16 19:13:44 AEDT 2003
Reduce inappropriate dependencies on ll_backend modules. Except for
simplification of unnecessarily complicated logic in dependency_graph.m,
this change only moves functionality around.
compiler/llds_out.m:
compiler/c_util.m:
compiler/name_mangle.m:
Move predicates that are used by multiple backends from
ll_backend__llds_out to backend_libs__c_util and to a new module
backend_libs__name_mangle. Make the relevant ones functions,
and give some of them more meaningful names.
compiler/trace.m:
compiler/hlds_goal.m:
Move a backend-independent predicate from ll_backend__trace
to hlds__hlds_goal.
compiler/llds.m:
compiler/trace_params.m:
Move the definition of the trace_port type from ll_backend__llds
to libs__trace_params to avoid having libs__trace_params depend on
ll_backend.
compiler/exprn_aux.m:
compiler/globals.m:
Move the definition of the imported_is_constant from
ll_backend__exprn_aux to libs__globals to avoid having libs__globals
depend on ll_backend.
compiler/*.m:
Conform to the above changes. This removes many inappropriate
dependencies on the LLDS backend.
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/aditi_backend.pp
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/aditi_backend.pp,v
retrieving revision 1.2
diff -u -b -r1.2 aditi_backend.pp
--- compiler/aditi_backend.pp 15 Mar 2003 03:08:42 -0000 1.2
+++ compiler/aditi_backend.pp 16 Mar 2003 06:19:48 -0000
@@ -71,9 +71,7 @@
%-----------------------------------------------------------------------------%
:- implementation.
- % aditi_backend__rl_exprn uses ll_backend__llds
- % and backend_libs__builtin_ops.
-:- import_module ll_backend.
+ % aditi_backend__rl_exprn uses backend_libs__builtin_ops.
:- import_module backend_libs.
:- end_module aditi_backend.
Index: compiler/backend_libs.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/backend_libs.m,v
retrieving revision 1.3
diff -u -b -r1.3 backend_libs.m
--- compiler/backend_libs.m 14 Mar 2003 08:10:04 -0000 1.3
+++ compiler/backend_libs.m 15 Mar 2003 18:48:49 -0000
@@ -27,16 +27,12 @@
:- include_module export.
:- include_module foreign.
:- include_module matching.
+:- include_module name_mangle.
:- include_module proc_label.
:- include_module pseudo_type_info.
:- include_module rtti.
:- include_module switch_util.
:- include_module type_ctor_info.
-
-%-----------------------------------------------------------------------------%
-
-:- implementation.
-:- import_module ll_backend. % XXX for llds_out__name_mangle.
:- end_module backend_libs.
Index: compiler/base_typeclass_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/base_typeclass_info.m,v
retrieving revision 1.23
diff -u -b -r1.23 base_typeclass_info.m
--- compiler/base_typeclass_info.m 15 Mar 2003 03:08:42 -0000 1.23
+++ compiler/base_typeclass_info.m 15 Mar 2003 19:36:00 -0000
@@ -43,7 +43,6 @@
:- import_module hlds__hlds_pred.
:- import_module libs__globals.
:- import_module libs__options.
-:- import_module ll_backend__code_util.
:- import_module parse_tree__prog_io.
:- import_module parse_tree__prog_out.
Index: compiler/c_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/c_util.m,v
retrieving revision 1.14
diff -u -b -r1.14 c_util.m
--- compiler/c_util.m 15 Mar 2003 03:08:42 -0000 1.14
+++ compiler/c_util.m 15 Mar 2003 11:22:58 -0000
@@ -135,6 +135,18 @@
:- mode c_util__binary_infix_op(in, out) is semidet.
%-----------------------------------------------------------------------------%
+
+ % output_c_file_intro_and_grade(SourceFileName, Version)
+ % outputs a comment which includes the settings used to generate
+ % the C file. This is used by configure to check the any
+ % existing C files are consistent with the current
+ % configuration. SourceFileName is the name of the file from
+ % which the C is generated, while Version is the version name
+ % of the mercury compiler.
+:- pred output_c_file_intro_and_grade(string, string, io__state, io__state).
+:- mode output_c_file_intro_and_grade(in, in, di, uo) is det.
+
+%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
@@ -372,5 +384,37 @@
c_util__binary_infix_op(>, ">").
c_util__binary_infix_op(<=, "<=").
c_util__binary_infix_op(>=, ">=").
+
+%-----------------------------------------------------------------------------%
+
+output_c_file_intro_and_grade(SourceFileName, Version) -->
+ globals__io_lookup_int_option(num_tag_bits, NumTagBits),
+ { string__int_to_string(NumTagBits, NumTagBitsStr) },
+ globals__io_lookup_bool_option(unboxed_float, UnboxedFloat),
+ { UnboxedFloatStr = convert_bool_to_string(UnboxedFloat) },
+
+ io__write_strings(["/*\n",
+ "** Automatically generated from `", SourceFileName,
+ "' by the Mercury compiler,\n",
+ "** version ", Version, ".\n",
+ "** Do not edit.\n",
+ "**\n",
+ "** The autoconfigured grade settings governing\n",
+ "** the generation of this C file were\n",
+ "**\n",
+ "** TAG_BITS=", NumTagBitsStr, "\n",
+ "** UNBOXED_FLOAT=", UnboxedFloatStr, "\n",
+ "**\n",
+ "** END_OF_C_GRADE_INFO\n",
+ "*/\n",
+ "\n",
+ "#define MR_TYPE_CTOR_INFO_HAS_FLAG 1\n",
+ "\n"
+ ]).
+
+:- func convert_bool_to_string(bool) = string.
+
+convert_bool_to_string(no) = "no".
+convert_bool_to_string(yes) = "yes".
%-----------------------------------------------------------------------------%
Index: compiler/check_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/check_hlds.m,v
retrieving revision 1.2
diff -u -b -r1.2 check_hlds.m
--- compiler/check_hlds.m 15 Mar 2003 03:08:43 -0000 1.2
+++ compiler/check_hlds.m 15 Mar 2003 18:49:39 -0000
@@ -70,7 +70,6 @@
:- implementation.
:- import_module transform_hlds. % for pd_cost, etc.
-:- import_module ll_backend. % XXX for code_util, code_aux
:- end_module check_hlds.
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.273
diff -u -b -r1.273 code_info.m
--- compiler/code_info.m 15 Mar 2003 07:11:55 -0000 1.273
+++ compiler/code_info.m 15 Mar 2003 20:26:28 -0000
@@ -38,6 +38,7 @@
:- import_module hlds__hlds_pred.
:- import_module hlds__instmap.
:- import_module libs__globals.
+:- import_module libs__trace_params.
:- import_module ll_backend__continuation_info.
:- import_module ll_backend__llds.
:- import_module ll_backend__trace.
@@ -51,7 +52,6 @@
:- import_module check_hlds__type_util.
:- import_module hlds__hlds_code_util.
:- import_module libs__options.
-:- import_module libs__trace_params.
:- import_module libs__tree.
:- import_module ll_backend__arg_info.
:- import_module ll_backend__code_exprn.
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.42
diff -u -b -r1.42 compile_target_code.m
--- compiler/compile_target_code.m 15 Mar 2003 03:08:43 -0000 1.42
+++ compiler/compile_target_code.m 15 Mar 2003 11:25:59 -0000
@@ -164,17 +164,17 @@
io__state::di, io__state::uo) is det.
%-----------------------------------------------------------------------------%
+
:- implementation.
:- import_module backend_libs__foreign.
+:- import_module backend_libs__name_mangle.
:- import_module hlds__error_util.
:- import_module hlds__passes_aux.
:- import_module libs__globals.
:- import_module libs__handle_options.
:- import_module libs__options.
:- import_module libs__trace_params.
-:- import_module ll_backend__llds_out. % for llds_out__make_init_name and
- % llds_out__make_rl_data_name
:- import_module parse_tree__prog_out.
:- import_module char, dir, getopt, int, require, string.
@@ -739,15 +739,13 @@
globals__io_lookup_bool_option(aditi, Aditi),
list__foldl(
(pred(ModuleName::in, di, uo) is det -->
- { llds_out__make_init_name(ModuleName,
- InitFuncName0) },
+ { InitFuncName0 = make_init_name(ModuleName) },
{ InitFuncName = InitFuncName0 ++ "init" },
io__write_string(InitFileStream, "INIT "),
io__write_string(InitFileStream, InitFuncName),
io__nl(InitFileStream),
( { Aditi = yes } ->
- { llds_out__make_rl_data_name(ModuleName,
- RLName) },
+ { RLName = make_rl_data_name(ModuleName) },
io__write_string(InitFileStream,
"ADITI_DATA "),
io__write_string(InitFileStream, RLName),
Index: compiler/continuation_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/continuation_info.m,v
retrieving revision 1.47
diff -u -b -r1.47 continuation_info.m
--- compiler/continuation_info.m 15 Mar 2003 03:08:43 -0000 1.47
+++ compiler/continuation_info.m 15 Mar 2003 19:44:29 -0000
@@ -57,6 +57,7 @@
:- import_module hlds__hlds_pred.
:- import_module hlds__instmap.
:- import_module libs__globals.
+:- import_module libs__trace_params.
:- import_module ll_backend__llds.
:- import_module ll_backend__trace.
:- import_module parse_tree__inst.
Index: compiler/dependency_graph.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dependency_graph.m,v
retrieving revision 1.58
diff -u -b -r1.58 dependency_graph.m
--- compiler/dependency_graph.m 15 Mar 2003 03:08:44 -0000 1.58
+++ compiler/dependency_graph.m 15 Mar 2003 12:29:11 -0000
@@ -100,21 +100,17 @@
:- implementation.
+:- import_module backend_libs__name_mangle.
+:- import_module backend_libs__proc_label.
:- import_module check_hlds__mode_util.
:- import_module hlds__goal_util.
:- import_module hlds__hlds_data.
:- import_module hlds__hlds_goal.
:- import_module libs__globals.
:- import_module libs__options.
-:- import_module ll_backend__code_util.
:- import_module parse_tree__mercury_to_mercury.
:- import_module parse_tree__prog_data.
-% XXX we should not import llds here -- this should depend only on the HLDS,
-% not on the LLDS. But the LLDS stuff is unfortunately needed for producing
-% the LLDS labels used for dependency_graph__write_prof_dependency_graph.
-:- import_module ll_backend__llds, ll_backend__llds_out.
-
:- import_module term, varset.
:- import_module int, bool, term, require, string.
:- import_module map, multi_map, set, std_util.
@@ -582,23 +578,8 @@
:- mode dependency_graph__output_label(in, in, in, di, uo) is det.
dependency_graph__output_label(ModuleInfo, PredId, ProcId) -->
- { code_util__make_entry_label(ModuleInfo, PredId, ProcId, no,
- Address) },
- (
- { Address = label(local(ProcLabela)) }
- ->
- output_label(local(ProcLabela))
- ;
- { Address = imported(ProcLabelb) }
- ->
- output_proc_label(ProcLabelb)
- ;
- { Address = label(exported(ProcLabelc)) }
- ->
- output_label(exported(ProcLabelc))
- ;
- { error("dependency_graph__output_label: label not of type local or imported or exported\n") }
- ).
+ { ProcLabel = make_proc_label(ModuleInfo, PredId, ProcId) },
+ output_proc_label(ProcLabel).
%-----------------------------------------------------------------------------%
Index: compiler/export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.65
diff -u -b -r1.65 export.m
--- compiler/export.m 14 Mar 2003 08:10:06 -0000 1.65
+++ compiler/export.m 15 Mar 2003 11:26:26 -0000
@@ -69,6 +69,7 @@
:- import_module backend_libs__code_model.
:- import_module backend_libs__foreign.
+:- import_module backend_libs__name_mangle.
:- import_module backend_libs__proc_label.
:- import_module check_hlds__type_util.
:- import_module hlds__error_util.
@@ -78,7 +79,6 @@
:- import_module ll_backend__arg_info.
:- import_module ll_backend__code_gen.
:- import_module ll_backend__code_util.
-:- import_module ll_backend__llds_out.
:- import_module parse_tree__modules.
:- import_module term, varset.
@@ -240,7 +240,7 @@
copy_output_args(ArgInfoTypes, 0, Module, OutputArgs),
ProcLabel = make_proc_label(Module, PredId, ProcId),
- llds_out__get_proc_label(ProcLabel, yes, ProcLabelString),
+ ProcLabelString = proc_label_to_c_string(ProcLabel, yes),
string__append_list([
"\n",
@@ -630,7 +630,7 @@
SourceFileName,
"' by the\n** Mercury compiler, version ", Version,
".\n** Do not edit.\n*/\n"]),
- { llds_out__sym_name_mangle(ModuleName, MangledModuleName) },
+ { MangledModuleName = sym_name_mangle(ModuleName) },
{ string__to_upper(MangledModuleName, UppercaseModuleName) },
{ string__append(UppercaseModuleName, "_H", GuardMacroName) },
io__write_strings([
Index: compiler/exprn_aux.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/exprn_aux.m,v
retrieving revision 1.44
diff -u -b -r1.44 exprn_aux.m
--- compiler/exprn_aux.m 15 Mar 2003 03:08:45 -0000 1.44
+++ compiler/exprn_aux.m 16 Mar 2003 05:46:40 -0000
@@ -29,12 +29,6 @@
:- pred exprn_aux__const_is_constant(rval_const::in, exprn_opts::in, bool::out)
is det.
- % exprn_aux__imported_is_constant(NonLocalGotos, AsmLabels, IsConst)
- % figures out whether an imported label address is a constant.
- % This depends on how we treat labels.
-
-:- pred exprn_aux__imported_is_constant(bool::in, bool::in, bool::out) is det.
-
:- pred exprn_aux__rval_contains_lval(rval::in, lval::in) is semidet.
:- pred exprn_aux__rval_contains_rval(rval, rval).
@@ -105,6 +99,7 @@
:- implementation.
+:- import_module libs__globals.
:- import_module libs__options.
:- import_module int, set, require, getopt.
@@ -159,7 +154,7 @@
exprn_aux__label_is_constant(Label, NonLocalGotos, AsmLabels, IsConst).
exprn_aux__addr_is_constant(imported(_), ExprnOpts, IsConst) :-
ExprnOpts = nlg_asm_sgt_ubf(NonLocalGotos, AsmLabels, _SGT, _UBF),
- exprn_aux__imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
+ globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
exprn_aux__addr_is_constant(succip, _, no).
exprn_aux__addr_is_constant(do_succeed(_), _, no).
exprn_aux__addr_is_constant(do_redo, _, no).
@@ -182,32 +177,11 @@
is det.
exprn_aux__label_is_constant(exported(_), NonLocalGotos, AsmLabels, IsConst) :-
- exprn_aux__imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
+ globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
exprn_aux__label_is_constant(local(_), NonLocalGotos, AsmLabels, IsConst) :-
- exprn_aux__imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
+ globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
exprn_aux__label_is_constant(c_local(_), _NonLocalGotos, _AsmLabels, yes).
exprn_aux__label_is_constant(local(_, _), _NonLocalGotos, _AsmLabels, yes).
-
- % The logic of this function and how it is used in globals.m to
- % select the default type_info method must agree with the code in
- % runtime/typeinfo.h.
-
-exprn_aux__imported_is_constant(NonLocalGotos, AsmLabels, IsConst) :-
- (
- NonLocalGotos = yes,
- AsmLabels = no
- ->
- %
- % with non-local gotos but no asm labels, jumps to code
- % addresses in different c_modules must be done via global
- % variables; the value of these global variables is not
- % constant (i.e. not computable at load time), since they
- % can't be initialized until we call init_modules().
- %
- IsConst = no
- ;
- IsConst = yes
- ).
%------------------------------------------------------------------------------%
Index: compiler/fact_table.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/fact_table.m,v
retrieving revision 1.45
diff -u -b -r1.45 fact_table.m
--- compiler/fact_table.m 15 Mar 2003 03:08:45 -0000 1.45
+++ compiler/fact_table.m 15 Mar 2003 11:27:49 -0000
@@ -106,8 +106,10 @@
:- import_module ll_backend__llds.
:- import_module ll_backend__llds_out.
% Modules shared between different back-ends.
+:- import_module backend_libs__c_util.
:- import_module backend_libs__code_model.
:- import_module backend_libs__export.
+:- import_module backend_libs__name_mangle.
:- import_module backend_libs__foreign.
% Misc
:- import_module libs__globals.
@@ -1342,7 +1344,7 @@
{ Arg = term__string(String) },
io__set_output_stream(OutputStream, OldStream),
io__write_string(""""),
- output_c_quoted_string(String),
+ c_util__output_quoted_string(String),
io__write_string(""", "),
io__set_output_stream(OldStream, _)
;
@@ -2308,7 +2310,7 @@
{ Key = term__string(String) }
->
io__write_string(""""),
- output_c_quoted_string(String),
+ c_util__output_quoted_string(String),
io__write_string("""")
;
{ Key = term__integer(Int) }
@@ -2453,10 +2455,11 @@
io__set_output_stream(OldOutputStream, _).
%---------------------------------------------------------------------------%
+
:- pred make_fact_table_identifier(sym_name::in, string::out) is det.
make_fact_table_identifier(SymName, Identifier) :-
- llds_out__sym_name_mangle(SymName, Identifier).
+ Identifier = sym_name_mangle(SymName).
%---------------------------------------------------------------------------%
Index: compiler/foreign.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.26
diff -u -b -r1.26 foreign.m
--- compiler/foreign.m 15 Mar 2003 03:08:45 -0000 1.26
+++ compiler/foreign.m 15 Mar 2003 11:28:20 -0000
@@ -223,6 +223,7 @@
:- implementation.
:- import_module backend_libs__code_model.
+:- import_module backend_libs__name_mangle.
:- import_module check_hlds__mode_util.
:- import_module check_hlds__type_util.
:- import_module hlds__error_util.
@@ -841,10 +842,8 @@
%-----------------------------------------------------------------------------%
-:- import_module ll_backend__llds_out.
-
decl_guard(ModuleName) = UppercaseModuleName ++ "_DECL_GUARD" :-
- llds_out__sym_name_mangle(ModuleName, MangledModuleName),
+ MangledModuleName = sym_name_mangle(ModuleName),
string__to_upper(MangledModuleName, UppercaseModuleName).
%-----------------------------------------------------------------------------%
Index: compiler/globals.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.54
diff -u -b -r1.54 globals.m
--- compiler/globals.m 15 Mar 2003 03:08:45 -0000 1.54
+++ compiler/globals.m 16 Mar 2003 05:44:58 -0000
@@ -149,6 +149,12 @@
:- pred globals__want_return_var_layouts(globals::in, bool::out) is det.
+ % globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst)
+ % figures out whether an imported label address is a constant.
+ % This depends on how we treat labels.
+
+:- pred globals__imported_is_constant(bool::in, bool::in, bool::out) is det.
+
%-----------------------------------------------------------------------------%
% Access predicates for storing a `globals' structure in the
@@ -384,7 +390,7 @@
getopt__lookup_bool_option(OptionTable, gcc_non_local_gotos,
NonLocalGotos),
getopt__lookup_bool_option(OptionTable, asm_labels, AsmLabels),
- exprn_aux__imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
+ globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
globals__want_return_var_layouts(Globals, WantReturnLayouts) :-
% We need to generate layout info for call return labels
@@ -403,6 +409,26 @@
WantReturnLayouts = yes
;
WantReturnLayouts = no
+ ).
+
+ % The logic of this function and how it is used to select the default
+ % type_info method must agree with the code in runtime/typeinfo.h.
+
+globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst) :-
+ (
+ NonLocalGotos = yes,
+ AsmLabels = no
+ ->
+ %
+ % with non-local gotos but no asm labels, jumps to code
+ % addresses in different c_modules must be done via global
+ % variables; the value of these global variables is not
+ % constant (i.e. not computable at load time), since they
+ % can't be initialized until we call init_modules().
+ %
+ IsConst = no
+ ;
+ IsConst = yes
).
%-----------------------------------------------------------------------------%
Index: compiler/hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds.m,v
retrieving revision 1.209
diff -u -b -r1.209 hlds.m
--- compiler/hlds.m 15 Mar 2003 03:08:48 -0000 1.209
+++ compiler/hlds.m 15 Mar 2003 19:42:31 -0000
@@ -14,7 +14,7 @@
:- import_module check_hlds. % needed for unify_proc__unify_proc_id,
% etc.
:- import_module libs.
-% :- import_module ll_backend. % XXX needed for `llds__lval',
+:- import_module ll_backend. % XXX needed for `llds__lval',
% which is used in various annotations
% in the HLDS (stack_slots, follow_vars, etc.)
:- import_module parse_tree.
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.103
diff -u -b -r1.103 hlds_goal.m
--- compiler/hlds_goal.m 15 Mar 2003 03:08:49 -0000 1.103
+++ compiler/hlds_goal.m 15 Mar 2003 19:28:55 -0000
@@ -801,6 +801,10 @@
:- type maybe_cut ---> cut ; no_cut.
+ % Convert a goal path to a string, using the format documented
+ % in the Mercury user's guide.
+:- pred goal_path_to_string(goal_path::in, string::out) is det.
+
%-----------------------------------------------------------------------------%
%
% Miscellaneous utility procedures for dealing with HLDS goals
@@ -1383,6 +1387,44 @@
goal_has_feature(_Goal - GoalInfo, Feature) :-
goal_info_has_feature(GoalInfo, Feature).
+
+%-----------------------------------------------------------------------------%
+
+goal_path_to_string(Path, PathStr) :-
+ goal_path_steps_to_strings(Path, StepStrs),
+ list__reverse(StepStrs, RevStepStrs),
+ string__append_list(RevStepStrs, PathStr).
+
+:- pred goal_path_steps_to_strings(goal_path::in, list(string)::out) is det.
+
+goal_path_steps_to_strings([], []).
+goal_path_steps_to_strings([Step | Steps], [StepStr | StepStrs]) :-
+ goal_path_step_to_string(Step, StepStr),
+ goal_path_steps_to_strings(Steps, StepStrs).
+
+ % The inverse of this procedure is implemented in
+ % browser/program_representation.m, and must be updated if this
+ % is changed.
+
+:- pred goal_path_step_to_string(goal_path_step::in, string::out) is det.
+
+goal_path_step_to_string(conj(N), Str) :-
+ string__int_to_string(N, NStr),
+ string__append_list(["c", NStr, ";"], Str).
+goal_path_step_to_string(disj(N), Str) :-
+ string__int_to_string(N, NStr),
+ string__append_list(["d", NStr, ";"], Str).
+goal_path_step_to_string(switch(N, _), Str) :-
+ string__int_to_string(N, NStr),
+ string__append_list(["s", NStr, ";"], Str).
+goal_path_step_to_string(ite_cond, "?;").
+goal_path_step_to_string(ite_then, "t;").
+goal_path_step_to_string(ite_else, "e;").
+goal_path_step_to_string(neg, "~;").
+goal_path_step_to_string(exist(cut), "q!;").
+goal_path_step_to_string(exist(no_cut), "q;").
+goal_path_step_to_string(first, "f;").
+goal_path_step_to_string(later, "l;").
%-----------------------------------------------------------------------------%
%
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.299
diff -u -b -r1.299 hlds_out.m
--- compiler/hlds_out.m 15 Mar 2003 03:08:51 -0000 1.299
+++ compiler/hlds_out.m 15 Mar 2003 19:30:17 -0000
@@ -284,7 +284,6 @@
:- import_module ll_backend__code_util.
:- import_module ll_backend__llds.
:- import_module ll_backend__llds_out.
-:- import_module ll_backend__trace.
% Misc
:- import_module backend_libs__foreign.
@@ -1217,7 +1216,7 @@
{ goal_info_get_goal_path(GoalInfo, Path) },
( { Path \= [] } ->
% XXX should avoid dependency on trace.m here
- { trace__path_to_string(Path, PathStr) },
+ { goal_path_to_string(Path, PathStr) },
hlds_out__write_indent(Indent),
io__write_string("% goal path: "),
io__write_string(PathStr),
Index: compiler/layout_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/layout_out.m,v
retrieving revision 1.19
diff -u -b -r1.19 layout_out.m
--- compiler/layout_out.m 14 Mar 2003 08:10:06 -0000 1.19
+++ compiler/layout_out.m 15 Mar 2003 19:30:39 -0000
@@ -82,11 +82,12 @@
:- implementation.
:- import_module backend_libs__c_util.
+:- import_module backend_libs__name_mangle.
:- import_module backend_libs__rtti.
+:- import_module hlds__hlds_goal.
:- import_module hlds__hlds_pred.
:- import_module libs__trace_params.
:- import_module ll_backend__code_util.
-:- import_module ll_backend__trace.
:- import_module parse_tree__prog_data.
:- import_module parse_tree__prog_out.
@@ -197,7 +198,7 @@
% This code should be kept in sync with output_layout_name/3 below.
make_label_layout_name(Label) = Name :-
- llds_out__get_label(Label, yes, LabelName),
+ LabelName = label_to_c_string(Label, yes),
string__append_list([
mercury_data_prefix,
"_label_layout__",
@@ -208,8 +209,7 @@
% This code should be kept in sync with make_label_layout_name/1 above.
io__write_string(mercury_data_prefix),
io__write_string("_label_layout__"),
- { llds_out__get_label(Label, yes, LabelName) },
- io__write_string(LabelName).
+ io__write_string(label_to_c_string(Label, yes)).
output_layout_name(proc_layout(ProcLabel, _)) -->
io__write_string(mercury_data_prefix),
io__write_string("_proc_layout__"),
@@ -231,43 +231,43 @@
output_layout_name(file_layout(ModuleName, FileNum)) -->
io__write_string(mercury_data_prefix),
io__write_string("_file_layout__"),
- { llds_out__sym_name_mangle(ModuleName, ModuleNameStr) },
+ { ModuleNameStr = sym_name_mangle(ModuleName) },
io__write_string(ModuleNameStr),
io__write_string("_"),
io__write_int(FileNum).
output_layout_name(file_layout_line_number_vector(ModuleName, FileNum)) -->
io__write_string(mercury_data_prefix),
io__write_string("_file_lines__"),
- { llds_out__sym_name_mangle(ModuleName, ModuleNameStr) },
+ { ModuleNameStr = sym_name_mangle(ModuleName) },
io__write_string(ModuleNameStr),
io__write_string("_"),
io__write_int(FileNum).
output_layout_name(file_layout_label_layout_vector(ModuleName, FileNum)) -->
io__write_string(mercury_data_prefix),
io__write_string("_file_label_layouts__"),
- { llds_out__sym_name_mangle(ModuleName, ModuleNameStr) },
+ { ModuleNameStr = sym_name_mangle(ModuleName) },
io__write_string(ModuleNameStr),
io__write_string("_"),
io__write_int(FileNum).
output_layout_name(module_layout_string_table(ModuleName)) -->
io__write_string(mercury_data_prefix),
io__write_string("_module_strings__"),
- { llds_out__sym_name_mangle(ModuleName, ModuleNameStr) },
+ { ModuleNameStr = sym_name_mangle(ModuleName) },
io__write_string(ModuleNameStr).
output_layout_name(module_layout_file_vector(ModuleName)) -->
io__write_string(mercury_data_prefix),
io__write_string("_module_files__"),
- { llds_out__sym_name_mangle(ModuleName, ModuleNameStr) },
+ { ModuleNameStr = sym_name_mangle(ModuleName) },
io__write_string(ModuleNameStr).
output_layout_name(module_layout_proc_vector(ModuleName)) -->
io__write_string(mercury_data_prefix),
io__write_string("_module_procs__"),
- { llds_out__sym_name_mangle(ModuleName, ModuleNameStr) },
+ { ModuleNameStr = sym_name_mangle(ModuleName) },
io__write_string(ModuleNameStr).
output_layout_name(module_layout(ModuleName)) -->
io__write_string(mercury_data_prefix),
io__write_string("_module_layout__"),
- { llds_out__sym_name_mangle(ModuleName, ModuleNameStr) },
+ { ModuleNameStr = sym_name_mangle(ModuleName) },
io__write_string(ModuleNameStr).
output_layout_name(proc_static(RttiProcLabel)) -->
io__write_string(mercury_data_prefix),
@@ -1302,7 +1302,7 @@
io__write_string(""", "),
io__write_int(LineNumber),
io__write_string(", """),
- { trace__path_to_string(GoalPath, GoalPathStr) },
+ { goal_path_to_string(GoalPath, GoalPathStr) },
io__write_string(GoalPathStr),
io__write_string(""" },\n").
Index: compiler/libs.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/libs.m,v
retrieving revision 1.2
diff -u -b -r1.2 libs.m
--- compiler/libs.m 15 Mar 2003 03:08:54 -0000 1.2
+++ compiler/libs.m 15 Mar 2003 19:38:20 -0000
@@ -10,8 +10,6 @@
:- module libs.
:- interface.
-:- import_module ll_backend. % XXX trace_params depends on llds__trace_port.
-
% option handling
:- include_module globals.
:- include_module handle_options.
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.289
diff -u -b -r1.289 llds.m
--- compiler/llds.m 14 Mar 2003 08:10:06 -0000 1.289
+++ compiler/llds.m 15 Mar 2003 19:37:59 -0000
@@ -582,26 +582,6 @@
; gc
.
- % The kinds of events with which MR_trace may be called, either
- % by compiler-generated code, or by code in the standard library
- % referring to compiler-generated data structures.
-:- type trace_port
- ---> call
- ; exit
- ; fail
- ; redo
- ; exception
- ; ite_cond
- ; ite_then
- ; ite_else
- ; neg_enter
- ; neg_success
- ; neg_failure
- ; switch
- ; disj
- ; nondet_pragma_first
- ; nondet_pragma_later.
-
% Each call instruction has a list of liveinfo, which stores
% information about which variables are live after the call
% (that is, on return). The information is intended for use by
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.206
diff -u -b -r1.206 llds_out.m
--- compiler/llds_out.m 15 Mar 2003 03:08:55 -0000 1.206
+++ compiler/llds_out.m 15 Mar 2003 11:22:25 -0000
@@ -19,11 +19,8 @@
:- import_module aditi_backend__rl_file.
:- import_module backend_libs__builtin_ops.
-:- import_module backend_libs__proc_label.
-:- import_module hlds__hlds_data.
:- import_module libs__globals.
:- import_module ll_backend__llds.
-:- import_module parse_tree__prog_data.
:- import_module bool, std_util, list, map, io.
@@ -36,16 +33,6 @@
:- pred output_llds(c_file::in, map(label, data_addr)::in, maybe(rl_file)::in,
io__state::di, io__state::uo) is det.
- % output_c_file_intro_and_grade(SourceFileName, Version)
- % outputs a comment which includes the settings used to generate
- % the C file. This is used by configure to check the any
- % existing C files are consistent with the current
- % configuration. SourceFileName is the name of the file from
- % which the C is generated, while Version is the version name
- % of the mercury compiler.
-:- pred output_c_file_intro_and_grade(string, string, io__state, io__state).
-:- mode output_c_file_intro_and_grade(in, in, di, uo) is det.
-
% output_rval_decls(Rval, FirstIndent, LaterIndent, N0, N,
% DeclSet0, DeclSet) outputs the declarations of any static constants,
% etc. that need to be declared before output_rval(Rval) is called.
@@ -102,10 +89,6 @@
:- pred output_data_addr(data_addr::in, io__state::di, io__state::uo) is det.
- % All the C data structures we generate which are either fully static
- % or static after initialization should have this prefix.
-:- func mercury_data_prefix = string.
-
% c_data_linkage_string(Globals, DefaultLinkage, StaticEvenIfSplit,
% BeingDefined):
% Return a C string that gives the storage class appropriate for the
@@ -151,87 +134,10 @@
:- pred output_label(label, io__state, io__state).
:- mode output_label(in, di, uo) is det.
- % Output a proc label (used for building static call graph for prof).
-
-:- pred output_proc_label(proc_label, io__state, io__state).
-:- mode output_proc_label(in, di, uo) is det.
-
- % Get a proc label string (used by procs which are exported to C).
- % The boolean controls whether a prefix ("mercury__") is added to the
- % proc label.
-
-:- pred llds_out__get_proc_label(proc_label, bool, string).
-:- mode llds_out__get_proc_label(in, in, out) is det.
-
- % Get a label string.
- % The boolean controls whether a prefix ("mercury__") is added to the
- % label.
-
-:- pred llds_out__get_label(label, bool, string).
-:- mode llds_out__get_label(in, in, out) is det.
-
- % Mangle an arbitrary name into a C identifier
-
-:- pred llds_out__name_mangle(string, string).
-:- mode llds_out__name_mangle(in, out) is det.
-
- % Mangle a possibly module-qualified Mercury symbol name
- % into a C identifier.
-
-:- pred llds_out__sym_name_mangle(sym_name, string).
-:- mode llds_out__sym_name_mangle(in, out) is det.
-
- % Produces a string of the form Module__Name.
-
-:- pred llds_out__qualify_name(string, string, string).
-:- mode llds_out__qualify_name(in, in, out) is det.
+ % Convert a label to a C string. The boolean controls whether
+ % a prefix ("mercury__") is added to the string.
- % Convert a string into a form suitable for outputting as a C string,
- % by converting special characters into backslashes escapes.
-:- pred llds_out__quote_c_string(string, string).
-:- mode llds_out__quote_c_string(in, out) is det.
-
- % Like quote_c_string except the resulting string is written to
- % the current output stream.
-:- pred output_c_quoted_string(string, io__state, io__state).
-:- mode output_c_quoted_string(in, di, uo) is det.
-
- % Like quote_c_quoted_string except that the string may have
- % NULL characters embedded in it.
-:- pred output_c_quoted_multi_string(int, string, io__state, io__state).
-:- mode output_c_quoted_multi_string(in, in, di, uo) is det.
-
- % Create a name for base_typeclass_info
-
-:- pred llds_out__make_base_typeclass_info_name(class_id, string, string).
-:- mode llds_out__make_base_typeclass_info_name(in, in, out) is det.
-
- % output the name for base_typeclass_info,
- % with the appropriate "mercury_data_" prefix.
-
-:- pred output_base_typeclass_info_name(class_id, string, io__state, io__state).
-:- mode output_base_typeclass_info_name(in, in, di, uo) is det.
-
- % Convert a label to a string description of the stack layout
- % structure of that label.
-
- % Returns the name of the initialization function
- % for a given module.
-
-:- pred llds_out__make_init_name(module_name, string).
-:- mode llds_out__make_init_name(in, out) is det.
-
- % Returns the name of the Aditi-RL code constant
- % for a given module.
-
-:- pred llds_out__make_rl_data_name(module_name, string).
-:- mode llds_out__make_rl_data_name(in, out) is det.
-
- % Print out the name of the tabling variable for the specified
- % procedure.
-
-:- pred output_tabling_pointer_var_name(proc_label::in,
- io__state::di, io__state::uo) is det.
+:- func llds_out__label_to_c_string(label, bool) = string.
% The following are exported to rtti_out. It may be worthwhile
% to put these in a new module (maybe llds_out_util).
@@ -277,6 +183,8 @@
:- import_module backend_libs__compile_target_code.
:- import_module backend_libs__export.
:- import_module backend_libs__foreign.
+:- import_module backend_libs__name_mangle.
+:- import_module backend_libs__proc_label.
:- import_module backend_libs__rtti.
:- import_module hlds__hlds_pred.
:- import_module hlds__passes_aux.
@@ -288,6 +196,7 @@
:- import_module ll_backend__rtti_out.
:- import_module parse_tree__mercury_to_mercury.
:- import_module parse_tree__modules.
+:- import_module parse_tree__prog_data.
:- import_module parse_tree__prog_out.
:- import_module parse_tree__prog_util.
@@ -475,37 +384,6 @@
{ GenBytecode = no }
).
-output_c_file_intro_and_grade(SourceFileName, Version) -->
- globals__io_lookup_int_option(num_tag_bits, NumTagBits),
- { string__int_to_string(NumTagBits, NumTagBitsStr) },
- globals__io_lookup_bool_option(unboxed_float, UnboxedFloat),
- { convert_bool_to_string(UnboxedFloat, UnboxedFloatStr) },
-
- io__write_strings(["/*\n",
- "** Automatically generated from `", SourceFileName,
- "' by the Mercury compiler,\n",
- "** version ", Version, ".\n",
- "** Do not edit.\n",
- "**\n",
- "** The autoconfigured grade settings governing\n",
- "** the generation of this C file were\n",
- "**\n",
- "** TAG_BITS=", NumTagBitsStr, "\n",
- "** UNBOXED_FLOAT=", UnboxedFloatStr, "\n",
- "**\n",
- "** END_OF_C_GRADE_INFO\n",
- "*/\n",
- "\n",
- "#define MR_TYPE_CTOR_INFO_HAS_FLAG 1\n",
- "\n"
- ]).
-
-:- pred convert_bool_to_string(bool, string).
-:- mode convert_bool_to_string(in, out) is det.
-
-convert_bool_to_string(no, "no").
-convert_bool_to_string(yes, "yes").
-
:- pred output_single_c_file(c_file, maybe(int), map(label, data_addr),
maybe(rl_file), io__state, io__state).
:- mode output_single_c_file(in, in, in, in, di, uo) is det.
@@ -866,7 +744,7 @@
io__write_string("init\n"),
globals__io_lookup_bool_option(aditi, Aditi),
( { Aditi = yes } ->
- { llds_out__make_rl_data_name(ModuleName, RLName) },
+ { RLName = make_rl_data_name(ModuleName) },
io__write_string("ADITI_DATA "),
io__write_string(RLName),
io__write_string("\n")
@@ -876,29 +754,12 @@
io__write_string("ENDINIT\n"),
io__write_string("*/\n\n").
-:- pred output_init_name(module_name, io__state, io__state).
-:- mode output_init_name(in, di, uo) is det.
-
-output_init_name(ModuleName) -->
- { llds_out__make_init_name(ModuleName, InitName) },
- io__write_string(InitName).
-
-llds_out__make_init_name(ModuleName, InitName) :-
- llds_out__sym_name_mangle(ModuleName, MangledModuleName),
- string__append_list(["mercury__", MangledModuleName, "__"],
- InitName).
-
-llds_out__make_rl_data_name(ModuleName, RLDataConstName) :-
- llds_out__sym_name_mangle(ModuleName, MangledModuleName),
- string__append("mercury__aditi_rl_data__", MangledModuleName,
- RLDataConstName).
-
:- pred output_bunch_name(module_name, string, int, io__state, io__state).
:- mode output_bunch_name(in, in, in, di, uo) is det.
output_bunch_name(ModuleName, InitStatus, Number) -->
io__write_string("mercury__"),
- { llds_out__sym_name_mangle(ModuleName, MangledModuleName) },
+ { MangledModuleName = sym_name_mangle(ModuleName) },
io__write_string(MangledModuleName),
io__write_string("_"),
io__write_string(InitStatus),
@@ -1012,10 +873,6 @@
{ DataAddr = data_addr(ModuleName, tabling_pointer(ProcLabel)) },
{ decl_set_insert(DeclSet0, data_addr(DataAddr), DeclSet) }.
-output_tabling_pointer_var_name(ProcLabel) -->
- io__write_string("mercury_var__table_root__"),
- output_proc_label(ProcLabel).
-
:- pred output_comp_gen_c_data_list(list(comp_gen_c_data)::in,
decl_set::in, decl_set::out, io__state::di, io__state::uo) is det.
@@ -1751,7 +1608,7 @@
{ FrameInfo = ordinary_frame(Msg, Num, MaybeStruct) },
( { MaybeStruct = yes(pragma_c_struct(StructName, _, _)) } ->
io__write_string("\tMR_mkpragmaframe("""),
- output_c_quoted_string(Msg),
+ c_util__output_quoted_string(Msg),
io__write_string(""", "),
io__write_int(Num),
io__write_string(", "),
@@ -1761,7 +1618,7 @@
io__write_string(");\n")
;
io__write_string("\tMR_mkframe("""),
- output_c_quoted_string(Msg),
+ c_util__output_quoted_string(Msg),
io__write_string(""", "),
io__write_int(Num),
io__write_string(", "),
@@ -1825,7 +1682,7 @@
{ ProfInfo = CallerLabel - _ },
output_label(CallerLabel),
io__write_string(", """),
- output_c_quoted_string(TypeMsg),
+ c_util__output_quoted_string(TypeMsg),
io__write_string(""");\n").
output_instruction(mark_hp(Lval), _) -->
@@ -1875,7 +1732,7 @@
io__write_string("\tMR_incr_sp_push_msg("),
io__write_int(N),
io__write_string(", """),
- output_c_quoted_string(Msg),
+ c_util__output_quoted_string(Msg),
io__write_string(""");\n").
output_instruction(decr_sp(N), _) -->
@@ -3487,15 +3344,13 @@
output_data_addr(layout_addr(LayoutName)) -->
output_layout_name(LayoutName).
-mercury_data_prefix = "mercury_data_".
-
:- pred output_data_addr(module_name::in, data_name::in,
io__state::di, io__state::uo) is det.
output_data_addr(ModuleName, VarName) -->
(
{ VarName = common(N) },
- { llds_out__sym_name_mangle(ModuleName, MangledModuleName) },
+ { MangledModuleName = sym_name_mangle(ModuleName) },
io__write_string(mercury_data_prefix),
io__write_string(MangledModuleName),
io__write_string("__common_"),
@@ -3608,153 +3463,21 @@
% in the recursive call.
output_label(Label) -->
- { llds_out__get_label(Label, yes, LabelStr) },
+ { LabelStr = llds_out__label_to_c_string(Label, yes) },
io__write_string(LabelStr).
-output_proc_label(ProcLabel) -->
- { llds_out__get_proc_label(ProcLabel, yes, ProcLabelString) },
- io__write_string(ProcLabelString).
-
-llds_out__get_label(exported(ProcLabel), AddPrefix, ProcLabelStr) :-
- llds_out__get_proc_label(ProcLabel, AddPrefix, ProcLabelStr).
-llds_out__get_label(local(ProcLabel), AddPrefix, ProcLabelStr) :-
- llds_out__get_proc_label(ProcLabel, AddPrefix, ProcLabelStr).
-llds_out__get_label(c_local(ProcLabel), AddPrefix, ProcLabelStr) :-
- llds_out__get_proc_label(ProcLabel, AddPrefix, ProcLabelStr).
-llds_out__get_label(local(Num, ProcLabel), AddPrefix, LabelStr) :-
- llds_out__get_proc_label(ProcLabel, AddPrefix, ProcLabelStr),
+llds_out__label_to_c_string(exported(ProcLabel), AddPrefix) =
+ proc_label_to_c_string(ProcLabel, AddPrefix).
+llds_out__label_to_c_string(local(ProcLabel), AddPrefix) =
+ proc_label_to_c_string(ProcLabel, AddPrefix).
+llds_out__label_to_c_string(c_local(ProcLabel), AddPrefix) =
+ proc_label_to_c_string(ProcLabel, AddPrefix).
+llds_out__label_to_c_string(local(Num, ProcLabel), AddPrefix) = LabelStr :-
+ ProcLabelStr = proc_label_to_c_string(ProcLabel, AddPrefix),
string__int_to_string(Num, NumStr),
string__append("_i", NumStr, NumSuffix),
string__append(ProcLabelStr, NumSuffix, LabelStr).
-%
-% Warning: any changes to the name mangling algorithm here will also
-% require changes to extras/dynamic_linking/name_mangle.m,
-% profiler/demangle.m and util/mdemangle.c.
-%
-llds_out__get_proc_label(proc(DefiningModule, PredOrFunc, PredModule,
- PredName, Arity, ModeNum0), AddPrefix, ProcLabelString) :-
- get_label_name(DefiningModule, PredOrFunc, PredModule,
- PredName, Arity, AddPrefix, LabelName),
- ( PredOrFunc = function ->
- OrigArity = Arity - 1
- ;
- OrigArity = Arity
- ),
- string__int_to_string(OrigArity, ArityString),
- proc_id_to_int(ModeNum0, ModeInt),
- string__int_to_string(ModeInt, ModeNumString),
- string__append_list([LabelName, "_", ArityString, "_", ModeNumString],
- ProcLabelString).
-
- % For a special proc, output a label of the form:
- % mercury____<PredName>___<TypeModule>__<TypeName>_<TypeArity>_<Mode>
-llds_out__get_proc_label(special_proc(Module, PredName, TypeModule,
- TypeName, TypeArity, ModeNum0), AddPrefix, ProcLabelString) :-
- % figure out the LabelName
- DummyArity = -1, % not used by get_label_name.
- get_label_name(unqualified(""), predicate, unqualified(""),
- PredName, DummyArity, AddPrefix, LabelName),
-
- % figure out the ModeNumString
- string__int_to_string(TypeArity, TypeArityString),
- proc_id_to_int(ModeNum0, ModeInt),
- string__int_to_string(ModeInt, ModeNumString),
-
- % mangle all the relevent names
- llds_out__sym_name_mangle(Module, MangledModule),
- llds_out__sym_name_mangle(TypeModule, MangledTypeModule),
- llds_out__name_mangle(TypeName, MangledTypeName),
-
- % Module-qualify the type name.
- % To handle locally produced unification preds for imported types,
- % we need to qualify it with both the module name of the
- % type, and also (if it is different) the module name of the
- % current module.
- llds_out__qualify_name(MangledTypeModule, MangledTypeName,
- QualifiedMangledTypeName),
- llds_out__maybe_qualify_name(MangledModule, QualifiedMangledTypeName,
- FullyQualifiedMangledTypeName),
-
- % join it all together
- string__append_list( [LabelName, "_", FullyQualifiedMangledTypeName,
- "_", TypeArityString, "_", ModeNumString],
- ProcLabelString).
-
- % get a label name, given the defining module, predicate or
- % function indicator, declaring module, predicate name, arity,
- % and whether or not to add a prefix.
-
-:- pred get_label_name(module_name, pred_or_func, module_name, string, arity,
- bool, string).
-:- mode get_label_name(in, in, in, in, in, in, out) is det.
-
-%
-% Warning: any changes to the name mangling algorithm here will also
-% require changes to extras/dynamic_linking/name_mangle.m,
-% profiler/demangle.m and util/mdemangle.c.
-%
-get_label_name(DefiningModule, PredOrFunc, DeclaringModule,
- Name0, Arity, AddPrefix, LabelName) :-
- llds_out__sym_name_mangle(DeclaringModule, DeclaringModuleName),
- llds_out__sym_name_mangle(DefiningModule, DefiningModuleName),
- (
- (
- mercury_private_builtin_module(DeclaringModule)
- ;
- mercury_public_builtin_module(DeclaringModule)
- ;
- Name0 = "main",
- Arity = 2
- ;
- string__prefix(Name0, "__")
- )
- % The conditions above define which labels are printed without
- % module qualification. XXX Changes to runtime/* are necessary
- % to allow `builtin' or `private_builtin' labels to be
- % qualified.
- ->
- LabelName0 = Name0
- ;
- llds_out__qualify_name(DeclaringModuleName, Name0,
- LabelName0)
- ),
- (
- % if this is a specialized version of a predicate
- % defined in some other module, then it needs both
- % module prefixes
- DefiningModule \= DeclaringModule
- ->
- string__append_list([DefiningModuleName, "__", LabelName0],
- LabelName1)
- ;
- LabelName1 = LabelName0
- ),
- llds_out__name_mangle(LabelName1, LabelName2),
- (
- PredOrFunc = function,
- string__append("fn__", LabelName2, LabelName3)
- ;
- PredOrFunc = predicate,
- LabelName3 = LabelName2
- ),
- (
- AddPrefix = yes
- ->
- get_label_prefix(Prefix),
- string__append(Prefix, LabelName3, LabelName)
- ;
- LabelName = LabelName3
- ).
-
- % To ensure that Mercury labels don't clash with C symbols, we
- % prefix them with `mercury__'.
-
-:- pred get_label_prefix(string).
-:- mode get_label_prefix(out) is det.
-
-get_label_prefix("mercury__").
-
:- pred output_reg(reg_type, int, io__state, io__state).
:- mode output_reg(in, in, di, uo) is det.
@@ -4063,14 +3786,14 @@
c_util__output_float_literal(FloatVal).
output_rval_const(string_const(String)) -->
io__write_string("MR_string_const("""),
- output_c_quoted_string(String),
+ c_util__output_quoted_string(String),
{ string__length(String, StringLength) },
io__write_string(""", "),
io__write_int(StringLength),
io__write_string(")").
output_rval_const(multi_string_const(Length, String)) -->
io__write_string("MR_string_const("""),
- output_c_quoted_multi_string(Length, String),
+ c_util__output_quoted_multi_string(Length, String),
io__write_string(""", "),
io__write_int(Length),
io__write_string(")").
@@ -4139,14 +3862,14 @@
c_util__output_float_literal(FloatVal).
output_rval_static_const(string_const(String)) -->
io__write_string("MR_string_const("""),
- output_c_quoted_string(String),
+ c_util__output_quoted_string(String),
{ string__length(String, StringLength) },
io__write_string(""", "),
io__write_int(StringLength),
io__write_string(")").
output_rval_static_const(multi_string_const(Length, String)) -->
io__write_string("MR_string_const("""),
- output_c_quoted_multi_string(Length, String),
+ c_util__output_quoted_multi_string(Length, String),
io__write_string(""", "),
io__write_int(Length),
io__write_string(")").
@@ -4279,15 +4002,6 @@
output_reset_line_num -->
c_util__reset_line_num.
-output_c_quoted_string(S) -->
- c_util__output_quoted_string(S).
-
-output_c_quoted_multi_string(Len, S) -->
- c_util__output_quoted_multi_string(Len, S).
-
-llds_out__quote_c_string(String, QuotedString) :-
- c_util__quote_string(String, QuotedString).
-
%-----------------------------------------------------------------------------%
:- pred output_binary_op(binary_op, io__state, io__state).
@@ -4338,149 +4052,6 @@
%-----------------------------------------------------------------------------%
-%
-% Warning: any changes to the name mangling algorithm here will also
-% require changes to extras/dynamic_linking/name_mangle.m,
-% profiler/demangle.m and util/mdemangle.c.
-%
-
-llds_out__sym_name_mangle(unqualified(Name), MangledName) :-
- llds_out__name_mangle(Name, MangledName).
-llds_out__sym_name_mangle(qualified(ModuleName, PlainName), MangledName) :-
- llds_out__sym_name_mangle(ModuleName, MangledModuleName),
- llds_out__name_mangle(PlainName, MangledPlainName),
- llds_out__qualify_name(MangledModuleName, MangledPlainName,
- MangledName).
-
- % Convert a Mercury predicate name into something that can form
- % part of a C identifier. This predicate is necessary because
- % quoted names such as 'name with embedded spaces' are valid
- % predicate names in Mercury.
-
-llds_out__name_mangle(Name, MangledName) :-
- (
- string__is_alnum_or_underscore(Name)
- ->
- % any names that start with `f_' are changed so that
- % they start with `f__', so that we can use names starting
- % with `f_' (followed by anything except an underscore)
- % without fear of name collisions
- (
- string__append("f_", Suffix, Name)
- ->
- string__append("f__", Suffix, MangledName)
- ;
- MangledName = Name
- )
- ;
- llds_out__convert_to_valid_c_identifier(Name, MangledName)
- ).
-
-:- pred llds_out__convert_to_valid_c_identifier(string, string).
-:- mode llds_out__convert_to_valid_c_identifier(in, out) is det.
-
-llds_out__convert_to_valid_c_identifier(String, Name) :-
- (
- llds_out__name_conversion_table(String, Name0)
- ->
- Name = Name0
- ;
- llds_out__convert_to_valid_c_identifier_2(String, Name0),
- string__append("f", Name0, Name)
- ).
-
-llds_out__qualify_name(Module0, Name0, Name) :-
- string__append_list([Module0, "__", Name0], Name).
-
- % Produces a string of the form Module__Name, unless Module__
- % is already a prefix of Name.
-
-:- pred llds_out__maybe_qualify_name(string, string, string).
-:- mode llds_out__maybe_qualify_name(in, in, out) is det.
-
-llds_out__maybe_qualify_name(Module0, Name0, Name) :-
- string__append(Module0, "__", UnderscoresModule),
- ( string__append(UnderscoresModule, _, Name0) ->
- Name = Name0
- ;
- string__append(UnderscoresModule, Name0, Name)
- ).
-
- % A table used to convert Mercury functors into
- % C identifiers. Feel free to add any new translations you want.
- % The C identifiers should start with "f_",
- % to avoid introducing name clashes.
- % If the functor name is not found in the table, then
- % we use a fall-back method which produces ugly names.
-
-:- pred llds_out__name_conversion_table(string, string).
-:- mode llds_out__name_conversion_table(in, out) is semidet.
-
-llds_out__name_conversion_table("\\=", "f_not_equal").
-llds_out__name_conversion_table(">=", "f_greater_or_equal").
-llds_out__name_conversion_table("=<", "f_less_or_equal").
-llds_out__name_conversion_table("=", "f_equal").
-llds_out__name_conversion_table("<", "f_less_than").
-llds_out__name_conversion_table(">", "f_greater_than").
-llds_out__name_conversion_table("-", "f_minus").
-llds_out__name_conversion_table("+", "f_plus").
-llds_out__name_conversion_table("*", "f_times").
-llds_out__name_conversion_table("/", "f_slash").
-llds_out__name_conversion_table(",", "f_comma").
-llds_out__name_conversion_table(";", "f_semicolon").
-llds_out__name_conversion_table("!", "f_cut").
-llds_out__name_conversion_table("{}", "f_tuple").
-llds_out__name_conversion_table("[|]", "f_cons").
-llds_out__name_conversion_table("[]", "f_nil").
-
- % This is the fall-back method.
- % Given a string, produce a C identifier
- % for that string by concatenating the decimal
- % expansions of the character codes in the string,
- % separated by undellines.
- % The C identifier will start with "f_"; this predicate
- % constructs everything except the initial "f".
- %
- % For example, given the input "\n\t" we return "_10_8".
-
-:- pred llds_out__convert_to_valid_c_identifier_2(string, string).
-:- mode llds_out__convert_to_valid_c_identifier_2(in, out) is det.
-
-llds_out__convert_to_valid_c_identifier_2(String, Name) :-
- (
- string__first_char(String, Char, Rest)
- ->
- % XXX This will cause ABI incompatibilities between
- % compilers which are built in grades that have
- % different character representations.
- char__to_int(Char, Code),
- string__int_to_string(Code, CodeString),
- string__append("_", CodeString, ThisCharString),
- llds_out__convert_to_valid_c_identifier_2(Rest, Name0),
- string__append(ThisCharString, Name0, Name)
- ;
- % String is the empty string
- Name = String
- ).
-
-%-----------------------------------------------------------------------------%
-
-llds_out__make_base_typeclass_info_name(class_id(ClassSym, ClassArity),
- TypeNames, Str) :-
- llds_out__sym_name_mangle(ClassSym, MangledClassString),
- string__int_to_string(ClassArity, ArityString),
- llds_out__name_mangle(TypeNames, MangledTypeNames),
- string__append_list(["base_typeclass_info_", MangledClassString,
- "__arity", ArityString, "__", MangledTypeNames], Str).
-
-output_base_typeclass_info_name(ClassId, TypeNames) -->
- { llds_out__make_base_typeclass_info_name(ClassId, TypeNames, Str) },
- io__write_string(mercury_data_prefix),
- io__write_string("__"),
- io__write_string(Str).
-
-%-----------------------------------------------------------------------------%
-
:- pred gather_c_file_labels(list(comp_gen_c_module)::in, list(label)::out)
is det.
@@ -4545,7 +4116,7 @@
[]
;
io__write_string("\n\n/* Aditi-RL code for this module. */\n"),
- { llds_out__make_rl_data_name(ModuleName, RLDataConstName) },
+ { RLDataConstName = make_rl_data_name(ModuleName) },
io__write_string("const char "),
io__write_string(RLDataConstName),
io__write_string("[] = {"),
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.280
diff -u -b -r1.280 mercury_compile.m
--- compiler/mercury_compile.m 15 Mar 2003 03:08:57 -0000 1.280
+++ compiler/mercury_compile.m 15 Mar 2003 12:31:05 -0000
@@ -126,32 +126,33 @@
:- import_module ml_backend__ml_util. % MLDS utility predicates
% miscellaneous compiler modules
-:- import_module parse_tree__prog_data.
-:- import_module hlds__hlds_module.
-:- import_module hlds__hlds_pred.
-:- import_module hlds__hlds_out.
-:- import_module ll_backend__llds.
:- import_module aditi_backend__rl.
-:- import_module parse_tree__mercury_to_mercury.
-:- import_module hlds__hlds_data.
-:- import_module ll_backend__layout.
-:- import_module transform_hlds__dependency_graph.
-:- import_module parse_tree__prog_util.
:- import_module aditi_backend__rl_dump.
:- import_module aditi_backend__rl_file.
-:- import_module libs__options.
-:- import_module libs__globals.
-:- import_module libs__trace_params.
+:- import_module backend_libs__compile_target_code.
+:- import_module backend_libs__name_mangle.
:- import_module check_hlds__goal_path.
+:- import_module hlds__hlds_data.
+:- import_module hlds__hlds_module.
+:- import_module hlds__hlds_out.
+:- import_module hlds__hlds_pred.
:- import_module hlds__passes_aux.
-:- import_module recompilation.
-:- import_module recompilation__usage.
-:- import_module recompilation__check.
+:- import_module libs__globals.
+:- import_module libs__options.
:- import_module libs__timestamp.
+:- import_module libs__trace_params.
+:- import_module ll_backend__layout.
+:- import_module ll_backend__llds.
:- import_module make.
:- import_module make__options_file.
:- import_module make__util.
-:- import_module backend_libs__compile_target_code.
+:- import_module parse_tree__mercury_to_mercury.
+:- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_util.
+:- import_module recompilation.
+:- import_module recompilation__check.
+:- import_module recompilation__usage.
+:- import_module transform_hlds__dependency_graph.
% inter-module analysis framework
:- import_module analysis.
@@ -3565,7 +3566,7 @@
{ C_InterfaceInfo = foreign_interface_info(ModuleSymName,
C_HeaderCode0, C_Includes, C_BodyCode0,
_C_ExportDecls, C_ExportDefns) },
- { llds_out__sym_name_mangle(ModuleSymName, MangledModuleName) },
+ { MangledModuleName = sym_name_mangle(ModuleSymName) },
{ string__append(MangledModuleName, "_module", ModuleName) },
globals__io_lookup_int_option(procs_per_c_function, ProcsPerFunc),
{ get_c_body_code(C_BodyCode0, C_BodyCode) },
Index: compiler/ml_backend.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_backend.m,v
retrieving revision 1.3
diff -u -b -r1.3 ml_backend.m
--- compiler/ml_backend.m 15 Mar 2003 03:08:58 -0000 1.3
+++ compiler/ml_backend.m 15 Mar 2003 18:33:46 -0000
@@ -26,7 +26,6 @@
:- import_module check_hlds. % is this needed?
:- import_module hlds.
:- import_module libs.
-:- import_module ll_backend. % XXX needed for llds_out__name_mangle, etc.
:- import_module parse_tree.
:- import_module transform_hlds. % is this needed?
Index: compiler/ml_closure_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_closure_gen.m,v
retrieving revision 1.15
diff -u -b -r1.15 ml_closure_gen.m
--- compiler/ml_closure_gen.m 15 Mar 2003 03:08:58 -0000 1.15
+++ compiler/ml_closure_gen.m 15 Mar 2003 18:34:09 -0000
@@ -86,6 +86,7 @@
% XXX The following modules depend on the LLDS,
% so ideally they should not be used here.
+:- import_module ll_backend.
:- import_module ll_backend__continuation_info. % needed for
% `generate_closure_layout'
:- import_module ll_backend__llds. % needed for `layout_locn'
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.144
diff -u -b -r1.144 mlds_to_c.m
--- compiler/mlds_to_c.m 15 Mar 2003 03:09:00 -0000 1.144
+++ compiler/mlds_to_c.m 15 Mar 2003 11:21:26 -0000
@@ -67,6 +67,7 @@
:- import_module backend_libs__c_util.
:- import_module backend_libs__code_model.
:- import_module backend_libs__foreign.
+:- import_module backend_libs__name_mangle.
:- import_module backend_libs__rtti. % for rtti__addr_to_string.
:- import_module check_hlds__type_util.
:- import_module hlds__error_util.
@@ -74,10 +75,6 @@
:- import_module hlds__passes_aux.
:- import_module libs__globals.
:- import_module libs__options.
-:- import_module ll_backend__llds_out. % XXX needed for llds_out__name_mangle,
- % llds_out__sym_name_mangle,
- % llds_out__make_base_typeclass_info_name,
- % output_c_file_intro_and_grade.
:- import_module ml_backend__ml_code_util.
% for ml_gen_public_field_decl_flags, which is
% used by the code that handles derived classes
@@ -295,7 +292,7 @@
io__nl,
mlds_indent(Indent),
io__write_string("#ifndef MR_HEADER_GUARD_"),
- { llds_out__sym_name_mangle(ModuleName, MangledModuleName) },
+ { MangledModuleName = sym_name_mangle(ModuleName) },
io__write_string(MangledModuleName),
io__nl,
mlds_indent(Indent),
@@ -1670,7 +1667,7 @@
mlds_output_fully_qualified(qual(ModuleName, Name), OutputFunc) -->
{ SymName = mlds_module_name_to_sym_name(ModuleName) },
- { llds_out__sym_name_mangle(SymName, MangledModuleName) },
+ { MangledModuleName = sym_name_mangle(SymName) },
io__write_string(MangledModuleName),
io__write_string("__"),
OutputFunc(Name).
@@ -1679,7 +1676,7 @@
:- mode mlds_output_module_name(in, di, uo) is det.
mlds_output_module_name(ModuleName) -->
- { llds_out__sym_name_mangle(ModuleName, MangledModuleName) },
+ { MangledModuleName = sym_name_mangle(ModuleName) },
io__write_string(MangledModuleName).
:- pred mlds_output_name(mlds__entity_name, io__state, io__state).
@@ -1689,7 +1686,7 @@
% if they are not needed.
mlds_output_name(type(Name, Arity)) -->
- { llds_out__name_mangle(Name, MangledName) },
+ { MangledName = name_mangle(Name) },
io__format("%s_%d", [s(MangledName), i(Arity)]).
mlds_output_name(data(DataName)) -->
mlds_output_data_name(DataName).
@@ -1713,7 +1710,7 @@
( { PredOrFunc = predicate, Suffix = "p" }
; { PredOrFunc = function, Suffix = "f" }
),
- { llds_out__name_mangle(Name, MangledName) },
+ { MangledName = name_mangle(Name) },
io__format("%s_%d_%s", [s(MangledName), i(Arity), s(Suffix)]),
( { MaybeDefiningModule = yes(DefiningModule) } ->
io__write_string("_in__"),
@@ -1723,8 +1720,8 @@
).
mlds_output_pred_label(special_pred(PredName, MaybeTypeModule,
TypeName, TypeArity)) -->
- { llds_out__name_mangle(PredName, MangledPredName) },
- { llds_out__name_mangle(TypeName, MangledTypeName) },
+ { MangledPredName = name_mangle(PredName) },
+ { MangledTypeName = name_mangle(TypeName) },
io__write_string(MangledPredName),
io__write_string("__"),
( { MaybeTypeModule = yes(TypeModule) } ->
@@ -1749,8 +1746,7 @@
{ rtti__addr_to_string(RttiTypeCtor, RttiName, RttiAddrName) },
io__write_string(RttiAddrName).
mlds_output_data_name(base_typeclass_info(ClassId, InstanceStr)) -->
- { llds_out__make_base_typeclass_info_name(ClassId, InstanceStr,
- Name) },
+ { Name = make_base_typeclass_info_name(ClassId, InstanceStr) },
io__write_string(Name).
mlds_output_data_name(module_layout) -->
{ error("mlds_to_c.m: NYI: module_layout") }.
@@ -3062,8 +3058,7 @@
:- mode mlds_output_mangled_name(in, di, uo) is det.
mlds_output_mangled_name(Name) -->
- { llds_out__name_mangle(Name, MangledName) },
- io__write_string(MangledName).
+ io__write_string(name_mangle(Name)).
:- pred mlds_output_bracketed_lval(mlds__lval, io__state, io__state).
:- mode mlds_output_bracketed_lval(in, di, uo) is det.
Index: compiler/mlds_to_gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.81
diff -u -b -r1.81 mlds_to_gcc.m
--- compiler/mlds_to_gcc.m 15 Mar 2003 03:09:00 -0000 1.81
+++ compiler/mlds_to_gcc.m 15 Mar 2003 18:39:46 -0000
@@ -151,13 +151,13 @@
:- import_module check_hlds.
:- import_module hlds.
:- import_module libs.
-:- import_module ll_backend. % XXX
:- import_module parse_tree.
% XXX some of these imports might be unused
:- import_module backend_libs__builtin_ops.
:- import_module backend_libs__code_model.
+:- import_module backend_libs__name_mangle.
:- import_module backend_libs__pseudo_type_info.
:- import_module backend_libs__rtti. % for rtti__addr_to_string.
:- import_module check_hlds__type_util.
@@ -166,9 +166,6 @@
:- import_module hlds__passes_aux.
:- import_module libs__globals.
:- import_module libs__options.
-:- import_module ll_backend__llds_out. % XXX needed for llds_out__name_mangle,
- % llds_out__sym_name_mangle,
- % llds_out__make_base_typeclass_info_name,
:- import_module ml_backend__ml_code_util.% for ml_gen_public_field_decl_flags,
% which is used by the code that handles
% derived classes
@@ -1174,7 +1171,7 @@
{ GCC_VarName = ml_var_name_to_string(VarName) },
gcc__build_static_var_decl(GCC_VarName, GCC_Type, GCC_InitExpr,
GCC_Defn),
- { llds_out__name_mangle(GCC_VarName, MangledVarName) },
+ { MangledVarName = name_mangle(GCC_VarName) },
gcc__set_var_decl_asm_name(GCC_Defn, MangledVarName),
add_var_decl_flags(Flags, GCC_Defn),
gcc__finish_static_var_decl(GCC_Defn)
@@ -1626,7 +1623,7 @@
( PredOrFunc = predicate, Suffix = "p"
; PredOrFunc = function, Suffix = "f"
),
- llds_out__name_mangle(Name, MangledName),
+ MangledName = name_mangle(Name),
string__format("%s_%d_%s", [s(MangledName), i(Arity), s(Suffix)],
LabelName0),
( MaybeDefiningModule = yes(DefiningModule) ->
@@ -1637,8 +1634,8 @@
).
get_pred_label_name(special_pred(PredName, MaybeTypeModule,
TypeName, TypeArity), LabelName) :-
- llds_out__name_mangle(PredName, MangledPredName),
- llds_out__name_mangle(TypeName, MangledTypeName),
+ MangledPredName = name_mangle(PredName),
+ MangledTypeName = name_mangle(TypeName),
TypeNameString = string__format("%s_%d",
[s(MangledTypeName), i(TypeArity)]),
( MaybeTypeModule = yes(TypeModule) ->
@@ -1650,19 +1647,19 @@
LabelName = string__append_list([MangledPredName, "__" | TypeNameList]).
:- func get_module_name(module_name) = string.
-get_module_name(ModuleName) = MangledModuleName :-
- llds_out__sym_name_mangle(ModuleName, MangledModuleName).
+
+get_module_name(ModuleName) = sym_name_mangle(ModuleName).
:- pred build_param_types(mlds__arg_types::in, global_info::in,
list(gcc__type)::out, gcc__param_types::out,
io__state::di, io__state::uo) is det.
build_param_types(ArgTypes, GlobalInfo, GCC_Types, ParamTypes) -->
- build_param_types(ArgTypes, GlobalInfo, GCC_Types, gcc__empty_param_types,
- ParamTypes).
+ build_param_types(ArgTypes, GlobalInfo, GCC_Types,
+ gcc__empty_param_types, ParamTypes).
-% build a list of parameter types, and prepend this list to the gcc__param_types list
-% passed as input
+% build a list of parameter types, and prepend this list to the
+% gcc__param_types list passed as input
:- pred build_param_types(mlds__arg_types::in, global_info::in,
list(gcc__type)::out, gcc__param_types::in, gcc__param_types::out,
io__state::di, io__state::uo) is det.
@@ -1670,7 +1667,8 @@
build_param_types([], _, [], ParamTypes, ParamTypes) --> [].
build_param_types([ArgType | ArgTypes], GlobalInfo, [GCC_Type | GCC_Types],
ParamTypes0, ParamTypes) -->
- build_param_types(ArgTypes, GlobalInfo, GCC_Types, ParamTypes0, ParamTypes1),
+ build_param_types(ArgTypes, GlobalInfo, GCC_Types,
+ ParamTypes0, ParamTypes1),
build_type(ArgType, GlobalInfo, GCC_Type),
{ ParamTypes = gcc__cons_param_types(GCC_Type, ParamTypes1) }.
@@ -2353,7 +2351,7 @@
:- func build_name(mlds__entity_name) = string.
build_name(type(Name, Arity)) = TypeName :-
- llds_out__name_mangle(Name, MangledName),
+ MangledName = name_mangle(Name),
TypeName = string__format("%s_%d", [s(MangledName), i(Arity)]).
build_name(data(DataName)) = build_data_name(DataName).
build_name(EntityName) = AsmFuncName :-
@@ -2363,17 +2361,15 @@
:- func build_data_name(mlds__data_name) = string.
-build_data_name(var(Name)) = MangledName :-
- llds_out__name_mangle(ml_var_name_to_string(Name), MangledName).
+build_data_name(var(Name)) = name_mangle(ml_var_name_to_string(Name)).
build_data_name(common(Num)) =
string__format("common_%d", [i(Num)]).
build_data_name(rtti(RttiTypeCtor0, RttiName0)) = RttiAddrName :-
RttiTypeCtor = fixup_rtti_type_ctor(RttiTypeCtor0),
RttiName = fixup_rtti_name(RttiName0),
rtti__addr_to_string(RttiTypeCtor, RttiName, RttiAddrName).
-build_data_name(base_typeclass_info(ClassId, InstanceStr)) = Name :-
- llds_out__make_base_typeclass_info_name(ClassId, InstanceStr,
- Name).
+build_data_name(base_typeclass_info(ClassId, InstanceStr)) =
+ make_base_typeclass_info_name(ClassId, InstanceStr).
build_data_name(module_layout) = _ :-
sorry(this_file, "module_layout").
build_data_name(proc_layout(_ProcLabel)) = _ :-
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.128
diff -u -b -r1.128 mlds_to_il.m
--- compiler/mlds_to_il.m 15 Mar 2003 03:09:00 -0000 1.128
+++ compiler/mlds_to_il.m 15 Mar 2003 19:19:17 -0000
@@ -138,7 +138,7 @@
:- import_module backend_libs__c_util.
:- import_module backend_libs__code_model.
:- import_module backend_libs__foreign.
-:- import_module backend_libs__foreign.
+:- import_module backend_libs__name_mangle.
:- import_module backend_libs__pseudo_type_info.
:- import_module backend_libs__rtti.
:- import_module check_hlds__type_util.
@@ -147,7 +147,6 @@
:- import_module libs__globals.
:- import_module libs__options.
:- import_module libs__tree.
-:- import_module ll_backend__llds_out.
:- import_module ml_backend__il_peephole.
:- import_module ml_backend__ml_code_util.
:- import_module ml_backend__ml_type_gen.
@@ -157,8 +156,6 @@
:- import_module parse_tree__prog_out.
:- import_module parse_tree__prog_util.
-:- use_module ll_backend__llds. /* for user_foreign_code */
-
:- import_module bool, int, map, string, set, list, assoc_list, term.
:- import_module library, require, counter.
@@ -1276,9 +1273,8 @@
= string__format("common_%s", [i(Int)]).
mangle_dataname(rtti(RttiTypeCtor, RttiName)) = MangledName :-
rtti__addr_to_string(RttiTypeCtor, RttiName, MangledName).
-mangle_dataname(base_typeclass_info(ClassId, InstanceStr)) = MangledName :-
- llds_out__make_base_typeclass_info_name(ClassId, InstanceStr,
- MangledName).
+mangle_dataname(base_typeclass_info(ClassId, InstanceStr)) =
+ make_base_typeclass_info_name(ClassId, InstanceStr).
mangle_dataname(module_layout) = _MangledName :-
error("unimplemented: mangling module_layout").
mangle_dataname(proc_layout(_)) = _MangledName :-
@@ -3224,7 +3220,7 @@
i(Arity), s(PredOrFuncStr), s(MaybeProcIdInt),
s(MaybeSeqNumStr)], UnMangledId),
Id = UnMangledId.
- % llds_out__name_mangle(UnMangledId, Id).
+ % Id = name_mangle(UnMangledId).
predlabel_to_id(special_pred(PredName, MaybeModuleName, TypeName, Arity),
ProcId, MaybeSeqNum, Id) :-
@@ -3244,7 +3240,7 @@
[s(MaybeModuleStr), s(PredName), s(TypeName), i(Arity),
i(ProcIdInt), s(MaybeSeqNumStr)], UnMangledId),
Id = UnMangledId.
- % llds_out__name_mangle(UnMangledId, Id).
+ % Id = name_mangle(UnMangledId).
% If an mlds__var is not an argument or a local, what is it?
@@ -3404,8 +3400,7 @@
mangle_dataname(rtti(RttiTypeCtor, RttiName), MangledName) :-
rtti__addr_to_string(RttiTypeCtor, RttiName, MangledName).
mangle_dataname(base_typeclass_info(ClassId, InstanceStr), MangledName) :-
- llds_out__make_base_typeclass_info_name(ClassId, InstanceStr,
- MangledName).
+ MangledName = make_base_typeclass_info_name(ClassId, InstanceStr).
mangle_dataname(module_layout, _MangledName) :-
error("unimplemented: mangling module_layout").
mangle_dataname(proc_layout(_), _MangledName) :-
Index: compiler/mlds_to_java.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_java.m,v
retrieving revision 1.37
diff -u -b -r1.37 mlds_to_java.m
--- compiler/mlds_to_java.m 15 Mar 2003 03:09:01 -0000 1.37
+++ compiler/mlds_to_java.m 15 Mar 2003 11:36:16 -0000
@@ -67,6 +67,7 @@
:- import_module backend_libs__c_util.
:- import_module backend_libs__export. % for export__type_to_type_string
:- import_module backend_libs__foreign.
+:- import_module backend_libs__name_mangle.
:- import_module backend_libs__rtti. % for rtti__addr_to_string.
:- import_module check_hlds__type_util.
:- import_module hlds__error_util.
@@ -74,9 +75,6 @@
:- import_module hlds__passes_aux.
:- import_module libs__globals.
:- import_module libs__options.
-:- import_module ll_backend__llds_out. % XXX needed for llds_out__name_mangle,
- % llds_out__sym_name_mangle,
- % llds_out__make_base_typeclass_info_name,
:- import_module ml_backend__java_util.
:- import_module ml_backend__ml_code_util. % for ml_gen_local_var_decl_flags.
:- import_module ml_backend__ml_type_gen. % for ml_gen_type_name
@@ -263,13 +261,13 @@
:- mode mangle_mlds_sym_name_for_java(in, in, out) is det.
mangle_mlds_sym_name_for_java(unqualified(Name), _Qualifier, JavaSafeName) :-
- llds_out__name_mangle(Name, MangledName),
+ MangledName = name_mangle(Name),
JavaSafeName = valid_symbol_name(MangledName).
mangle_mlds_sym_name_for_java(qualified(ModuleName, PlainName), Qualifier,
MangledName) :-
mangle_mlds_sym_name_for_java(ModuleName, Qualifier,
MangledModuleName),
- llds_out__name_mangle(PlainName, MangledPlainName),
+ MangledPlainName = name_mangle(PlainName),
JavaSafePlainName = valid_symbol_name(MangledPlainName),
java_qualify_mangled_name(MangledModuleName, JavaSafePlainName,
Qualifier, MangledName).
@@ -280,7 +278,6 @@
java_qualify_mangled_name(Module0, Name0, Qualifier, Name) :-
string__append_list([Module0, Qualifier, Name0], Name).
-
%-----------------------------------------------------------------------------%
%
% Name mangling code to fix problem of mercury modules having the same name
@@ -736,7 +733,7 @@
%
ModuleNameStr = mlds_module_name_to_string(ModuleQualifier),
ClassEntityName = "AddrOf__" ++ ModuleNameStr ++ "__" ++ PredName,
- llds_out__name_mangle(ClassEntityName, MangledClassEntityName),
+ MangledClassEntityName = name_mangle(ClassEntityName),
%
% Put it all together.
%
@@ -913,23 +910,23 @@
( PredOrFunc = predicate, Suffix = "p", OrigArity = PredArity
; PredOrFunc = function, Suffix = "f", OrigArity = PredArity - 1
),
- llds_out__name_mangle(Name, MangledName),
+ MangledName = name_mangle(Name),
PredLabelStr0 = MangledName ++ "_"
++ string__int_to_string(OrigArity) ++ "_"
++ Suffix,
( MaybeDefiningModule = yes(DefiningModule) ->
- llds_out__sym_name_mangle(DefiningModule, MangledModuleName),
+ MangledModuleName = sym_name_mangle(DefiningModule),
PredLabelStr = PredLabelStr0 ++ "_in__" ++ MangledModuleName
;
PredLabelStr = PredLabelStr0
).
pred_label_string(special_pred(PredName, MaybeTypeModule,
TypeName, TypeArity)) = PredLabelStr :-
- llds_out__name_mangle(PredName, MangledPredName),
- llds_out__name_mangle(TypeName, MangledTypeName),
+ MangledPredName = name_mangle(PredName),
+ MangledTypeName = name_mangle(TypeName),
PredLabelStr0 = MangledPredName ++ "__",
( MaybeTypeModule = yes(TypeModule) ->
- llds_out__sym_name_mangle(TypeModule, MangledModuleName),
+ MangledModuleName = sym_name_mangle(TypeModule),
PredLabelStr1 = PredLabelStr0 ++ "__" ++ MangledModuleName
;
PredLabelStr1 = PredLabelStr0
@@ -937,8 +934,6 @@
PredLabelStr = PredLabelStr1 ++ MangledTypeName ++ "_" ++
string__int_to_string(TypeArity).
-
-
%------------------------------------------------------------------------------
%
% Code to output the start and end of a source file.
@@ -1567,14 +1562,13 @@
:- mode output_module_name(in, di, uo) is det.
output_module_name(ModuleName) -->
- { llds_out__sym_name_mangle(ModuleName, MangledModuleName) },
- io__write_string(MangledModuleName).
+ io__write_string(sym_name_mangle(ModuleName)).
:- pred output_class_name(mlds__entity_name, io__state, io__state).
:- mode output_class_name(in, di, uo) is det.
output_class_name(type(Name, Arity)) -->
- { llds_out__name_mangle(Name, MangledName) },
+ { MangledName = name_mangle(Name) },
io__format("%s_%d", [s(MangledName), i(Arity)]).
output_class_name(data(_)) --> [].
@@ -1585,7 +1579,7 @@
:- mode output_name(in, di, uo) is det.
output_name(type(Name, Arity)) -->
- { llds_out__name_mangle(Name, MangledName) },
+ { MangledName = name_mangle(Name) },
io__format("%s_%d", [s(MangledName), i(Arity)]).
output_name(data(DataName)) -->
output_data_name(DataName).
@@ -1609,7 +1603,7 @@
( { PredOrFunc = predicate, Suffix = "p", OrigArity = PredArity }
; { PredOrFunc = function, Suffix = "f", OrigArity = PredArity - 1 }
),
- { llds_out__name_mangle(Name, MangledName) },
+ { MangledName = name_mangle(Name) },
io__format("%s_%d_%s", [s(MangledName), i(OrigArity), s(Suffix)]),
( { MaybeDefiningModule = yes(DefiningModule) } ->
io__write_string("_in__"),
@@ -1618,10 +1612,10 @@
[]
).
-output_pred_label(special_pred(PredName, MaybeTypeModule,
- TypeName, TypeArity)) -->
- { llds_out__name_mangle(PredName, MangledPredName) },
- { llds_out__name_mangle(TypeName, MangledTypeName) },
+output_pred_label(special_pred(PredName, MaybeTypeModule, TypeName,
+ TypeArity)) -->
+ { MangledPredName = name_mangle(PredName) },
+ { MangledTypeName = name_mangle(TypeName) },
io__write_string(MangledPredName),
io__write_string("__"),
( { MaybeTypeModule = yes(TypeModule) } ->
@@ -1657,9 +1651,7 @@
{ rtti__addr_to_string(RttiTypeCtor, RttiName, RttiAddrName) },
io__write_string(RttiAddrName).
output_data_name(base_typeclass_info(ClassId, InstanceStr)) -->
- { llds_out__make_base_typeclass_info_name(ClassId, InstanceStr,
- Name) },
- io__write_string(Name).
+ io__write_string(make_base_typeclass_info_name(ClassId, InstanceStr)).
output_data_name(module_layout) -->
{ error("mlds_to_java.m: NYI: module_layout") }.
output_data_name(proc_layout(_ProcLabel)) -->
@@ -2567,7 +2559,7 @@
io__write_char('.'),
{ QualifiedCtorId = qual(_ModuleName, CtorDefn) },
{ CtorDefn = ctor_id(CtorName, CtorArity) },
- { llds_out__name_mangle(CtorName, MangledCtorName) },
+ { MangledCtorName = name_mangle(CtorName) },
io__format("%s_%d", [s(MangledCtorName), i(CtorArity)])
;
output_type(Type)
@@ -2716,7 +2708,7 @@
_FieldType, _PtrType)) -->
(
{ FieldName = qual(_, UnqualFieldName) },
- { llds_out__name_mangle(UnqualFieldName, MangledFieldName) },
+ { MangledFieldName = name_mangle(UnqualFieldName) },
{ MangledFieldName = "data_tag" }
->
%
@@ -2751,8 +2743,7 @@
:- mode output_mangled_name(in, di, uo) is det.
output_mangled_name(Name) -->
- { llds_out__name_mangle(Name, MangledName) },
- io__write_string(MangledName).
+ io__write_string(name_mangle(Name)).
:- pred mlds_output_bracketed_lval(mlds__lval, io__state, io__state).
:- mode mlds_output_bracketed_lval(in, di, uo) is det.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.268
diff -u -b -r1.268 modules.m
--- compiler/modules.m 15 Mar 2003 03:09:03 -0000 1.268
+++ compiler/modules.m 15 Mar 2003 12:34:16 -0000
@@ -744,10 +744,10 @@
:- implementation.
:- import_module backend_libs__foreign.
+:- import_module backend_libs__name_mangle.
:- import_module hlds__passes_aux.
:- import_module libs__handle_options.
:- import_module libs__options.
-:- import_module ll_backend__llds_out.
:- import_module make. % XXX undesirable dependency
:- import_module parse_tree__mercury_to_mercury.
:- import_module parse_tree__module_qual.
@@ -4737,9 +4737,9 @@
:- mode append_to_init_list(in, in, in, di, uo) is det.
append_to_init_list(DepStream, InitFileName, Module) -->
- { llds_out__make_init_name(Module, InitFuncName0) },
+ { InitFuncName0 = make_init_name(Module) },
{ string__append(InitFuncName0, "init", InitFuncName) },
- { llds_out__make_rl_data_name(Module, RLName) },
+ { RLName = make_rl_data_name(Module) },
io__write_strings(DepStream, [
"\techo ""INIT ", InitFuncName, """ >> ", InitFileName, "\n"
]),
Index: compiler/opt_debug.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/opt_debug.m,v
retrieving revision 1.125
diff -u -b -r1.125 opt_debug.m
--- compiler/opt_debug.m 14 Mar 2003 08:10:06 -0000 1.125
+++ compiler/opt_debug.m 15 Mar 2003 11:39:02 -0000
@@ -124,6 +124,7 @@
:- implementation.
+:- import_module backend_libs__name_mangle.
:- import_module hlds__hlds_pred.
:- import_module libs__globals.
:- import_module libs__options.
@@ -356,7 +357,7 @@
string__int_to_string(N, N_str),
string__append("common", N_str, Str).
opt_debug__dump_data_name(base_typeclass_info(ClassId, InstanceNum), Str) :-
- llds_out__make_base_typeclass_info_name(ClassId, InstanceNum, Str).
+ Str = make_base_typeclass_info_name(ClassId, InstanceNum).
opt_debug__dump_data_name(tabling_pointer(ProcLabel), Str) :-
opt_debug__dump_proclabel(ProcLabel, ProcLabelStr),
string__append_list(["tabling_pointer(", ProcLabelStr, ")"], Str).
@@ -367,8 +368,8 @@
opt_debug__dump_rtti_type_ctor(rtti_type_ctor(ModuleName, TypeName, Arity),
Str) :-
- llds_out__sym_name_mangle(ModuleName, ModuleName_str),
- llds_out__name_mangle(TypeName, TypeName_str),
+ ModuleName_str = sym_name_mangle(ModuleName),
+ TypeName_str = name_mangle(TypeName),
string__int_to_string(Arity, Arity_str),
string__append_list(["rtti_type_ctor(", ModuleName_str, ", ",
TypeName_str, Arity_str, ")"], Str).
@@ -419,7 +420,7 @@
Str = "type_ctor_info".
opt_debug__dump_rtti_name(base_typeclass_info(_ModuleName, ClassId,
InstanceStr), Str) :-
- llds_out__make_base_typeclass_info_name(ClassId, InstanceStr, Str).
+ Str = make_base_typeclass_info_name(ClassId, InstanceStr).
opt_debug__dump_rtti_name(type_info(_TypeInfo), Str) :-
% XXX should give more info than this
Str = "type_info".
@@ -457,36 +458,36 @@
string__append_list(["closure_proc_id(", ProcLabelStr, ", ",
SeqNoStr, ")"], Str).
opt_debug__dump_layout_name(file_layout(ModuleName, FileNum), Str) :-
- llds_out__sym_name_mangle(ModuleName, ModuleNameStr),
+ ModuleNameStr = sym_name_mangle(ModuleName),
string__int_to_string(FileNum, FileNumStr),
string__append_list(["file_layout(", ModuleNameStr, ", ",
FileNumStr, ")"], Str).
opt_debug__dump_layout_name(file_layout_line_number_vector(ModuleName,
FileNum), Str) :-
- llds_out__sym_name_mangle(ModuleName, ModuleNameStr),
+ ModuleNameStr = sym_name_mangle(ModuleName),
string__int_to_string(FileNum, FileNumStr),
string__append_list(["file_layout_line_number_vector(", ModuleNameStr,
", ", FileNumStr, ")"], Str).
opt_debug__dump_layout_name(file_layout_label_layout_vector(ModuleName,
FileNum), Str) :-
- llds_out__sym_name_mangle(ModuleName, ModuleNameStr),
+ ModuleNameStr = sym_name_mangle(ModuleName),
string__int_to_string(FileNum, FileNumStr),
string__append_list(["file_layout_label_layout_vector(", ModuleNameStr,
", ", FileNumStr, ")"], Str).
opt_debug__dump_layout_name(module_layout_string_table(ModuleName), Str) :-
- llds_out__sym_name_mangle(ModuleName, ModuleNameStr),
+ ModuleNameStr = sym_name_mangle(ModuleName),
string__append_list(["module_layout_string_table(", ModuleNameStr,
")"], Str).
opt_debug__dump_layout_name(module_layout_file_vector(ModuleName), Str) :-
- llds_out__sym_name_mangle(ModuleName, ModuleNameStr),
+ ModuleNameStr = sym_name_mangle(ModuleName),
string__append_list(["module_layout_file_vector(", ModuleNameStr, ")"],
Str).
opt_debug__dump_layout_name(module_layout_proc_vector(ModuleName), Str) :-
- llds_out__sym_name_mangle(ModuleName, ModuleNameStr),
+ ModuleNameStr = sym_name_mangle(ModuleName),
string__append_list(["module_layout_proc_vector(", ModuleNameStr, ")"],
Str).
opt_debug__dump_layout_name(module_layout(ModuleName), Str) :-
- llds_out__sym_name_mangle(ModuleName, ModuleNameStr),
+ ModuleNameStr = sym_name_mangle(ModuleName),
string__append_list(["module_layout(", ModuleNameStr, ")"], Str).
opt_debug__dump_layout_name(proc_static(RttiProcLabel), Str) :-
ProcLabel = make_proc_label_from_rtti(RttiProcLabel),
@@ -607,10 +608,10 @@
( Module = PredModule ->
ExtraModule = ""
;
- llds_out__sym_name_mangle(PredModule, PredModuleName),
+ PredModuleName = sym_name_mangle(PredModule),
string__append(PredModuleName, "_", ExtraModule)
),
- llds_out__sym_name_mangle(Module, ModuleName),
+ ModuleName = sym_name_mangle(Module),
string__int_to_string(Arity, A_str),
proc_id_to_int(ProcId, Mode),
string__int_to_string(Mode, M_str),
@@ -618,9 +619,9 @@
"_", A_str, "_", M_str], Str).
opt_debug__dump_proclabel(special_proc(Module, Pred, TypeModule,
Type, Arity, ProcId), Str) :-
- llds_out__sym_name_mangle(Module, ModuleName),
- llds_out__sym_name_mangle(TypeModule, TypeModuleName),
- llds_out__qualify_name(TypeModuleName, Type, TypeName),
+ ModuleName = sym_name_mangle(Module),
+ TypeModuleName = sym_name_mangle(TypeModule),
+ TypeName = qualify_name(TypeModuleName, Type),
string__int_to_string(Arity, A_str),
proc_id_to_int(ProcId, Mode),
string__int_to_string(Mode, M_str),
Index: compiler/optimize.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/optimize.m,v
retrieving revision 1.35
diff -u -b -r1.35 optimize.m
--- compiler/optimize.m 15 Mar 2003 03:09:04 -0000 1.35
+++ compiler/optimize.m 15 Mar 2003 11:39:36 -0000
@@ -28,6 +28,7 @@
:- implementation.
+:- import_module backend_libs__name_mangle.
:- import_module backend_libs__proc_label.
:- import_module hlds__hlds_pred.
:- import_module hlds__passes_aux.
@@ -97,7 +98,7 @@
globals__io_lookup_bool_option(debug_opt, DebugOpt),
(
{ DebugOpt = yes },
- { llds_out__name_mangle(Name, MangledName) },
+ { MangledName = name_mangle(Name) },
{ PredProcId = proc(PredId, ProcId) },
{ pred_id_to_int(PredId, PredIdInt) },
{ proc_id_to_int(ProcId, ProcIdInt) },
Index: compiler/pragma_c_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/pragma_c_gen.m,v
retrieving revision 1.56
diff -u -b -r1.56 pragma_c_gen.m
--- compiler/pragma_c_gen.m 15 Mar 2003 03:09:06 -0000 1.56
+++ compiler/pragma_c_gen.m 15 Mar 2003 18:14:24 -0000
@@ -43,7 +43,9 @@
:- implementation.
+:- import_module backend_libs__c_util.
:- import_module backend_libs__foreign.
+:- import_module backend_libs__name_mangle.
:- import_module check_hlds__type_util.
:- import_module hlds__error_util.
:- import_module hlds__hlds_data.
@@ -489,7 +491,7 @@
;
module_info_pred_info(ModuleInfo, PredId, PredInfo),
pred_info_name(PredInfo, Name),
- llds_out__quote_c_string(Name, MangledName),
+ c_util__quote_string(Name, MangledName),
string__append_list(["\tMR_OBTAIN_GLOBAL_LOCK(""",
MangledName, """);\n"], ObtainLockStr),
ObtainLock = pragma_c_raw_code(ObtainLockStr,
@@ -629,12 +631,11 @@
:- func make_proc_label_string(module_info, pred_id, proc_id) = string.
make_proc_label_string(ModuleInfo, PredId, ProcId) = ProcLabelString :-
- code_util__make_entry_label(ModuleInfo, PredId, ProcId, no,
- CodeAddr),
+ code_util__make_entry_label(ModuleInfo, PredId, ProcId, no, CodeAddr),
( CodeAddr = imported(ProcLabel) ->
- llds_out__get_proc_label(ProcLabel, yes, ProcLabelString)
- ; CodeAddr = label(ProcLabel) ->
- llds_out__get_label(ProcLabel, yes, ProcLabelString)
+ ProcLabelString = proc_label_to_c_string(ProcLabel, yes)
+ ; CodeAddr = label(Label) ->
+ ProcLabelString = label_to_c_string(Label, yes)
;
error("unexpected code_addr in make_proc_label_hash_define")
).
@@ -922,7 +923,7 @@
SharedLastSuccessLabel = "MR_shared_success_last_"
++ ProcLabelString ++ ":\n",
- llds_out__get_label(SharedLabel, yes, LabelStr),
+ LabelStr = label_to_c_string(SharedLabel, yes),
string__format("\tMR_GOTO_LABEL(%s);\n", [s(LabelStr)],
GotoSharedLabel),
@@ -1334,8 +1335,8 @@
%---------------------------------------------------------------------------%
pragma_c_gen__struct_name(ModuleName, PredName, Arity, ProcId, StructName) :-
- llds_out__sym_name_mangle(ModuleName, MangledModuleName),
- llds_out__name_mangle(PredName, MangledPredName),
+ MangledModuleName = sym_name_mangle(ModuleName),
+ MangledPredName = name_mangle(PredName),
proc_id_to_int(ProcId, ProcNum),
string__int_to_string(Arity, ArityStr),
string__int_to_string(ProcNum, ProcNumStr),
Index: compiler/rl.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rl.m,v
retrieving revision 1.21
diff -u -b -r1.21 rl.m
--- compiler/rl.m 14 Mar 2003 08:10:10 -0000 1.21
+++ compiler/rl.m 15 Mar 2003 18:45:38 -0000
@@ -673,18 +673,16 @@
:- pred rl__mangle_ctor_name(sym_name::in, int::in, string::out) is det.
%-----------------------------------------------------------------------------%
+
:- implementation.
+:- import_module backend_libs__name_mangle.
:- import_module backend_libs__proc_label.
:- import_module check_hlds__mode_util.
:- import_module check_hlds__type_util.
:- import_module hlds__goal_form.
:- import_module libs__globals.
:- import_module libs__options.
-:- import_module ll_backend__code_aux.
-:- import_module ll_backend__code_util.
-:- import_module ll_backend__llds.
-:- import_module ll_backend__llds_out.
:- import_module parse_tree__prog_out.
:- import_module parse_tree__prog_util.
@@ -1090,7 +1088,7 @@
IsImported = (pred_info_is_imported(PredInfo) -> yes ; no),
ProcLabel = make_user_proc_label(ModuleName, IsImported,
PredOrFunc, PredModule, PredName, Arity, ProcId),
- llds_out__get_proc_label(ProcLabel, no, ProcLabelStr),
+ ProcLabelStr = proc_label_to_c_string(ProcLabel, no),
prog_out__sym_name_to_string(PredModule, PredModuleStr),
ProcName = rl_proc_name(Owner, PredModuleStr, ProcLabelStr, 2).
Index: compiler/rl_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rl_info.m,v
retrieving revision 1.3
diff -u -b -r1.3 rl_info.m
--- compiler/rl_info.m 15 Mar 2003 03:09:09 -0000 1.3
+++ compiler/rl_info.m 15 Mar 2003 18:46:23 -0000
@@ -238,6 +238,7 @@
:- mode rl_info_write_message(in, in, rl_info_di, rl_info_uo) is det.
%-----------------------------------------------------------------------------%
+
:- implementation.
:- import_module check_hlds__mode_util.
@@ -245,8 +246,6 @@
:- import_module hlds__hlds_goal.
:- import_module libs__globals.
:- import_module libs__options.
-:- import_module ll_backend__code_util.
-:- import_module ll_backend__llds_out.
:- import_module parse_tree__prog_out.
:- import_module int, require.
Index: compiler/rl_out.pp
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rl_out.pp,v
retrieving revision 1.19
diff -u -b -r1.19 rl_out.pp
--- compiler/rl_out.pp 28 Feb 2003 00:21:38 -0000 1.19
+++ compiler/rl_out.pp 16 Mar 2003 06:19:48 -0000
@@ -20,10 +20,13 @@
:- interface.
-:- import_module aditi_backend__rl, aditi_backend__rl_file.
+:- import_module aditi_backend__rl.
+:- import_module aditi_backend__rl_file.
:- import_module hlds__hlds_module.
+
#if INCLUDE_ADITI_OUTPUT % See ../Mmake.common.in.
-:- import_module aditi_backend__rl_code, libs__tree.
+:- import_module aditi_backend__rl_code.
+:- import_module libs__tree.
#else
#endif
@@ -55,22 +58,32 @@
#endif
%-----------------------------------------------------------------------------%
+
:- implementation.
-:- import_module ll_backend__code_util, hlds__hlds_data, hlds__hlds_pred.
-:- import_module parse_tree__prog_data, parse_tree__prog_out.
-:- import_module ll_backend__llds, libs__globals, libs__options, libs__tree.
-:- import_module check_hlds__type_util, hlds__passes_aux.
-:- import_module aditi_backend__rl_file, getopt, parse_tree__modules.
-:- import_module parse_tree__prog_util, aditi_backend__magic_util.
+:- import_module aditi_backend__magic_util.
+:- import_module aditi_backend__rl_file.
+:- import_module check_hlds__det_analysis.
+:- import_module check_hlds__type_util.
+:- import_module hlds__hlds_data.
:- import_module hlds__hlds_goal.
-:- import_module ll_backend__code_aux, check_hlds__det_analysis, hlds__instmap.
+:- import_module hlds__hlds_pred.
+:- import_module hlds__instmap.
+:- import_module hlds__passes_aux.
+:- import_module libs__globals.
+:- import_module libs__options.
+:- import_module libs__tree.
+:- import_module parse_tree__modules.
+:- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_out.
+:- import_module parse_tree__prog_util.
#if INCLUDE_ADITI_OUTPUT % See ../Mmake.common.in.
:- import_module aditi_backend__rl_exprn.
#else
#endif
+:- import_module getopt.
:- import_module assoc_list, bool, char, int, map, multi_map, require, set.
:- import_module string, term, libs__tree, varset.
Index: compiler/rtti.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti.m,v
retrieving revision 1.27
diff -u -b -r1.27 rtti.m
--- compiler/rtti.m 15 Mar 2003 03:09:09 -0000 1.27
+++ compiler/rtti.m 15 Mar 2003 11:42:27 -0000
@@ -631,10 +631,10 @@
:- implementation.
+:- import_module backend_libs__name_mangle.
:- import_module check_hlds__mode_util.
:- import_module check_hlds__type_util.
:- import_module hlds__hlds_data.
-:- import_module ll_backend__llds_out. % for name_mangle and sym_name_mangle
:- import_module parse_tree__prog_util. % for mercury_public_builtin_module
:- import_module int, string, require, varset.
@@ -865,9 +865,9 @@
RttiName = base_typeclass_info(_ModuleName, ClassId,
InstanceStr),
ClassId = class_id(ClassSym, ClassArity),
- llds_out__sym_name_mangle(ClassSym, MangledClassString),
+ MangledClassString = sym_name_mangle(ClassSym),
string__int_to_string(ClassArity, ArityString),
- llds_out__name_mangle(InstanceStr, MangledTypeNames),
+ MangledTypeNames = name_mangle(InstanceStr),
string__append_list(["base_typeclass_info_",
MangledClassString, "__arity", ArityString, "__",
MangledTypeNames], Str)
@@ -890,8 +890,8 @@
;
ModuleNameSym = ModuleNameSym0
),
- sym_name_mangle(ModuleNameSym, ModuleName),
- name_mangle(TypeName0, TypeName),
+ ModuleName = sym_name_mangle(ModuleNameSym),
+ TypeName = name_mangle(TypeName0),
string__int_to_string(TypeArity, ArityStr).
%-----------------------------------------------------------------------------%
Index: compiler/rtti_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_out.m,v
retrieving revision 1.33
diff -u -b -r1.33 rtti_out.m
--- compiler/rtti_out.m 15 Mar 2003 03:09:09 -0000 1.33
+++ compiler/rtti_out.m 15 Mar 2003 11:44:54 -0000
@@ -83,6 +83,7 @@
:- implementation.
:- import_module backend_libs__c_util.
+:- import_module backend_libs__name_mangle.
:- import_module backend_libs__pseudo_type_info.
:- import_module backend_libs__type_ctor_info.
:- import_module hlds__error_util.
@@ -1069,7 +1070,7 @@
output_rtti_addr(RttiTypeCtor, type_ctor_info),
io__write_string(",\n\t\t"),
{ RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName, Arity) },
- { llds_out__sym_name_mangle(ModuleName, ModuleNameString) },
+ { ModuleNameString = sym_name_mangle(ModuleName) },
{ string__append(ModuleNameString, "__", UnderscoresModule) },
(
{ string__append(UnderscoresModule, _, TypeName) }
@@ -1078,7 +1079,7 @@
;
io__write_string(UnderscoresModule)
),
- { llds_out__name_mangle(TypeName, MangledTypeName) },
+ { MangledTypeName = name_mangle(TypeName) },
io__write_string(MangledTypeName),
io__write_string("_"),
io__write_int(Arity),
@@ -1304,8 +1305,7 @@
InstanceStr, _) }
->
% rtti_data_to_name/3 does not handle this case
- output_base_typeclass_info_name(ClassId,
- InstanceStr)
+ output_base_typeclass_info_name(ClassId, InstanceStr)
;
{ rtti_data_to_name(RttiData, RttiTypeCtor, RttiName) },
output_addr_of_rtti_addr(RttiTypeCtor, RttiName)
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.76
diff -u -b -r1.76 stack_layout.m
--- compiler/stack_layout.m 14 Mar 2003 08:10:10 -0000 1.76
+++ compiler/stack_layout.m 15 Mar 2003 19:41:28 -0000
@@ -667,7 +667,7 @@
{ Return = no },
{ MaybePort = yes(Port) },
{ MaybeIsHidden = yes(IsHidden) },
- { trace__path_to_string(GoalPath, GoalPathStr) },
+ { goal_path_to_string(GoalPath, GoalPathStr) },
stack_layout__lookup_string_in_table(GoalPathStr, GoalPathNum),
{ MaybeGoalPath = yes(GoalPathNum) }
;
@@ -687,7 +687,7 @@
{ stack_layout__find_valid_return_context(
TargetsContexts, _, _, GoalPath) }
->
- { trace__path_to_string(GoalPath, GoalPathStr) },
+ { goal_path_to_string(GoalPath, GoalPathStr) },
stack_layout__lookup_string_in_table(GoalPathStr,
GoalPathNum),
{ MaybeGoalPath = yes(GoalPathNum) }
Index: compiler/trace.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace.m,v
retrieving revision 1.58
diff -u -b -r1.58 trace.m
--- compiler/trace.m 15 Mar 2003 03:09:12 -0000 1.58
+++ compiler/trace.m 15 Mar 2003 19:27:41 -0000
@@ -209,10 +209,6 @@
% for a redo event. Otherwise, generate empty code.
:- pred trace__maybe_setup_redo_event(trace_info::in, code_tree::out) is det.
- % Convert a goal path to a string, using the format documented
- % in the Mercury user's guide.
-:- pred trace__path_to_string(goal_path::in, string::out) is det.
-
%-----------------------------------------------------------------------------%
:- implementation.
@@ -1009,42 +1005,6 @@
).
%-----------------------------------------------------------------------------%
-
-trace__path_to_string(Path, PathStr) :-
- trace__path_steps_to_strings(Path, StepStrs),
- list__reverse(StepStrs, RevStepStrs),
- string__append_list(RevStepStrs, PathStr).
-
-:- pred trace__path_steps_to_strings(goal_path::in, list(string)::out) is det.
-
-trace__path_steps_to_strings([], []).
-trace__path_steps_to_strings([Step | Steps], [StepStr | StepStrs]) :-
- trace__path_step_to_string(Step, StepStr),
- trace__path_steps_to_strings(Steps, StepStrs).
-
- % The inverse of this procedure is implemented in
- % browser/program_representation.m, and must be updated if this
- % is changed.
-
-:- pred trace__path_step_to_string(goal_path_step::in, string::out) is det.
-
-trace__path_step_to_string(conj(N), Str) :-
- string__int_to_string(N, NStr),
- string__append_list(["c", NStr, ";"], Str).
-trace__path_step_to_string(disj(N), Str) :-
- string__int_to_string(N, NStr),
- string__append_list(["d", NStr, ";"], Str).
-trace__path_step_to_string(switch(N, _), Str) :-
- string__int_to_string(N, NStr),
- string__append_list(["s", NStr, ";"], Str).
-trace__path_step_to_string(ite_cond, "?;").
-trace__path_step_to_string(ite_then, "t;").
-trace__path_step_to_string(ite_else, "e;").
-trace__path_step_to_string(neg, "~;").
-trace__path_step_to_string(exist(cut), "q!;").
-trace__path_step_to_string(exist(no_cut), "q;").
-trace__path_step_to_string(first, "f;").
-trace__path_step_to_string(later, "l;").
:- pred trace__convert_external_port_type(external_trace_port::in,
trace_port::out) is det.
Index: compiler/trace_params.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace_params.m,v
retrieving revision 1.14
diff -u -b -r1.14 trace_params.m
--- compiler/trace_params.m 15 Mar 2003 03:09:12 -0000 1.14
+++ compiler/trace_params.m 15 Mar 2003 19:45:12 -0000
@@ -35,13 +35,33 @@
:- interface.
+:- import_module hlds.
:- import_module hlds__hlds_pred.
-:- import_module ll_backend__llds. % XXX for trace_port
:- import_module bool, std_util.
:- type trace_level.
:- type trace_suppress_items.
+
+ % The kinds of events with which MR_trace may be called, either
+ % by compiler-generated code, or by code in the standard library
+ % referring to compiler-generated data structures.
+:- type trace_port
+ ---> call
+ ; exit
+ ; fail
+ ; redo
+ ; exception
+ ; ite_cond
+ ; ite_then
+ ; ite_else
+ ; neg_enter
+ ; neg_success
+ ; neg_failure
+ ; switch
+ ; disj
+ ; nondet_pragma_first
+ ; nondet_pragma_later.
% The string should be the value of the --trace-level option;
% two bools should be the values of the `--require-tracing' and
Index: compiler/unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.124
diff -u -b -r1.124 unify_gen.m
--- compiler/unify_gen.m 14 Mar 2003 08:10:12 -0000 1.124
+++ compiler/unify_gen.m 15 Mar 2003 19:29:42 -0000
@@ -59,7 +59,6 @@
:- import_module ll_backend__continuation_info.
:- import_module ll_backend__layout.
:- import_module ll_backend__stack_layout.
-:- import_module ll_backend__trace.
:- import_module parse_tree__prog_data.
:- import_module parse_tree__prog_out.
@@ -655,7 +654,7 @@
{ term__context_file(Context, FileName) },
{ term__context_line(Context, LineNumber) },
{ goal_info_get_goal_path(GoalInfo, GoalPath) },
- { trace__path_to_string(GoalPath, GoalPathStr) },
+ { goal_path_to_string(GoalPath, GoalPathStr) },
code_info__get_cur_proc_label(CallerProcLabel),
code_info__get_next_closure_seq_no(SeqNo),
code_info__get_cell_counter(C0),
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
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/graphics
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/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/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/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 java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
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 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