[m-rev.] diff: fix (potential) namespace cleanliness problems in std lib
Julien Fischer
juliensf at csse.unimelb.edu.au
Mon Aug 6 19:04:08 AEST 2007
Estimated hours taken: 0.5
Branches: main
Fix a problem that was causing the namespace cleanliness check to
fail in the library directory.
compiler/prog_mutable.m:
For standard library modules prefix the globals used for
mutables with `mercury__'.
compiler/hlds_module.m:
Do likewise for the exported C functions introduced by
initialise and finalise declarations.
Julien.
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.152
diff -u -r1.152 hlds_module.m
--- compiler/hlds_module.m 25 Jul 2007 06:12:19 -0000 1.152
+++ compiler/hlds_module.m 6 Aug 2007 09:00:26 -0000
@@ -646,6 +646,7 @@
:- implementation.
:- import_module libs.compiler_util.
+:- import_module parse_tree.prog_util.
:- import_module assoc_list.
:- import_module counter.
@@ -939,29 +940,39 @@
% we may wish to revisit this code. The reference manual is therefore
% deliberately quiet on the subject.
%
-module_info_new_user_init_pred(SymName, Arity, CName, MI0, MI) :-
- InitPredCNames0 = MI0 ^ sub_info ^ user_init_pred_c_names,
+module_info_new_user_init_pred(SymName, Arity, CName, !MI) :-
+ InitPredCNames0 = !.MI ^ sub_info ^ user_init_pred_c_names,
UserInitPredNo = list.length(InitPredCNames0),
- module_info_get_name(MI0, ModuleSymName),
+ module_info_get_name(!.MI, ModuleSymName0),
+ ( mercury_std_library_module_name(ModuleSymName0) ->
+ ModuleSymName = add_outermost_qualifier("mercury", ModuleSymName0)
+ ;
+ ModuleSymName = ModuleSymName0
+ ),
ModuleName = prog_foreign.sym_name_mangle(ModuleSymName),
CName = string.format("%s__user_init_pred_%d",
[s(ModuleName), i(UserInitPredNo)]),
InitPredCNames = InitPredCNames0 ++ [SymName / Arity - CName],
- MI = MI0 ^ sub_info ^ user_init_pred_c_names := InitPredCNames.
+ !:MI = !.MI ^ sub_info ^ user_init_pred_c_names := InitPredCNames.
module_info_user_init_pred_c_names(MI, CNames) :-
InitPredCNames = MI ^ sub_info ^ user_init_pred_c_names,
CNames = assoc_list.values(InitPredCNames).
-module_info_new_user_final_pred(SymName, Arity, CName, MI0, MI) :-
- FinalPredCNames0 = MI0 ^ sub_info ^ user_final_pred_c_names,
+module_info_new_user_final_pred(SymName, Arity, CName, !MI) :-
+ FinalPredCNames0 = !.MI ^ sub_info ^ user_final_pred_c_names,
UserFinalPredNo = list.length(FinalPredCNames0),
- module_info_get_name(MI0, ModuleSymName),
+ module_info_get_name(!.MI, ModuleSymName0),
+ ( mercury_std_library_module_name(ModuleSymName0) ->
+ ModuleSymName = add_outermost_qualifier("mercury", ModuleSymName0)
+ ;
+ ModuleSymName = ModuleSymName0
+ ),
ModuleName = prog_foreign.sym_name_mangle(ModuleSymName),
CName = string.format("%s__user_final_pred_%d",
[s(ModuleName), i(UserFinalPredNo)]),
FinalPredCNames = FinalPredCNames0 ++ [SymName / Arity - CName],
- MI = MI0 ^ sub_info ^ user_final_pred_c_names := FinalPredCNames.
+ !:MI = !.MI ^ sub_info ^ user_final_pred_c_names := FinalPredCNames.
module_info_user_final_pred_c_names(MI, CNames) :-
FinalPredCNames = MI ^ sub_info ^ user_final_pred_c_names,
Index: compiler/prog_mutable.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_mutable.m,v
retrieving revision 1.22
diff -u -r1.22 prog_mutable.m
--- compiler/prog_mutable.m 12 Jun 2007 06:53:57 -0000 1.22
+++ compiler/prog_mutable.m 6 Aug 2007 09:00:26 -0000
@@ -410,9 +410,11 @@
:- implementation.
+:- import_module parse_tree.modules.
:- import_module parse_tree.prog_foreign.
:- import_module parse_tree.prog_mode.
:- import_module parse_tree.prog_type.
+:- import_module parse_tree.prog_util.
:- import_module list.
:- import_module maybe.
@@ -623,9 +625,15 @@
qualified(ModuleName, "pre_initialise_mutable_" ++ Name).
mutable_c_var_name(ModuleName, Name) = MangledCVarName :-
- RawCVarName = "mutable_variable_" ++ Name,
- QualifiedCVarName = qualified(ModuleName, RawCVarName),
- MangledCVarName = sym_name_mangle(QualifiedCVarName).
+ RawCVarName = "mutable_variable_" ++ Name,
+ QualifiedCVarName0 = qualified(ModuleName, RawCVarName),
+ ( mercury_std_library_module_name(ModuleName) ->
+ QualifiedCVarName =
+ add_outermost_qualifier("mercury", QualifiedCVarName0)
+ ;
+ QualifiedCVarName = QualifiedCVarName0
+ ),
+ MangledCVarName = sym_name_mangle(QualifiedCVarName).
mutable_mutex_var_name(TargetMutableVarName) = MutexVarName :-
MutexVarName = TargetMutableVarName ++ "_lock".
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list