[m-dev.] diff: module qualification of labels
Simon TAYLOR
stayl at students.cs.mu.oz.au
Tue Jul 15 18:13:21 AEST 1997
Hi Fergus,
You wrote:
> This code doesn't correct implement the comment anymore,
> so either you have a bug in the code, or a bug in the comment.
> I think the behaviour specified by the comment is better,
> because the alternative leads to unnecessarily long symbol names
> in the generated code. So I consider this a bug in the code.
Let's have another go at that.
Index: llds_out.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/llds_out.m,v
retrieving revision 1.49
diff -u -r1.49 llds_out.m
--- llds_out.m 1997/06/29 23:10:53 1.49
+++ llds_out.m 1997/07/15 08:10:27
@@ -62,11 +62,10 @@
:- pred llds_out__name_mangle(string, string).
:- mode llds_out__name_mangle(in, out) is det.
- % Produces a string of the form Module__Name, unless Module__
- % is already a prefix of Name.
+ % Produces a string of the form Module__Name.
-:- pred llds_out__maybe_qualify_name(string, string, string).
-:- mode llds_out__maybe_qualify_name(in, in, out) is det.
+:- pred llds_out__qualify_name(string, string, string).
+:- mode llds_out__qualify_name(in, in, out) is det.
:- pred output_c_quoted_string(string, io__state, io__state).
:- mode output_c_quoted_string(in, di, uo) is det.
@@ -2196,7 +2195,7 @@
% 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__maybe_qualify_name(MangledTypeModule, MangledTypeName,
+ llds_out__qualify_name(MangledTypeModule, MangledTypeName,
QualifiedMangledTypeName),
llds_out__maybe_qualify_name(MangledModule, QualifiedMangledTypeName,
FullyQualifiedMangledTypeName),
@@ -2227,7 +2226,7 @@
->
LabelName0 = Name0
;
- llds_out__maybe_qualify_name(DeclaringModule, Name0,
+ llds_out__qualify_name(DeclaringModule, Name0,
LabelName0)
),
(
@@ -2861,6 +2860,15 @@
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),
More information about the developers
mailing list