[m-rev.] For review: Improve the name mangling of foreign methods in the IL backend

Julien Fischer juliensf at csse.unimelb.edu.au
Tue Jun 5 17:44:18 AEST 2007


On Tue, 5 Jun 2007, Jonathan Morgan wrote:

> Estimated hours taken: 4
> Branches: main
>
> Improve the name mangling for foreign language methods under the IL backend.
> Currently, method names containing spaces, punctuation, and other unusual

Delete "Currently".

> characters are acceptable in IL (because all method names are quoted), but
> are not acceptable in C# or Managed C++.  This change converts all such
> foreign names that are not alphanumeric or underscore to a valid C
> identifier in the same way as in the C-based backends.
>
> compiler/mlds_to_il.m:
> 	Alter the name mangling routines to allow it to mangle foreign names

... to allow them ...

> 	differently from ordinary IL names.  Alter the forwarding methods for
> 	foreign routines to call the mangled version of the method in the
> 	foreign module, rather than calling one with the IL method name.
>
> compiler/mlds_to_managed.m:
> 	Alter the generation of foreign methods to use the new mangled name.
>

...

> @@ -3236,6 +3252,26 @@
> %
> % Name mangling.
>
> +:- type il_mangle_type --->
> +    mangle_il
> +        % Names that are to be used only in IL are able to include spaces,
> +        % punctuation and other special characters, because they are in 
> quotes.
> +    ; mangle_managed.
> +        % Names that are to be used in other managed languages (typically
> +        % because they define foreign procedures in that language) must be
> +        % mangled in much the same way as for C.

What does "in much the same way" mean?  Be precise, if it is the same
as in C then say so, if not what is the difference?

I suggest renaming the constructors for the above types as follows:

 	:- type il_mangle_name
 		--->	mangle_for_il
 		;	mangle_for_managed.

> +    % Create a mangled predicate identifier, suitable for use in IL.
> +    %
> +:- pred predlabel_to_id(mlds_pred_label::in, proc_id::in,
> +    maybe(mlds_func_sequence_num)::in, ilds.id::out) is det.
> +
> +predlabel_to_id(PredLabel, ProcId, MaybeSeqNum, Id) :-
> +    predlabel_to_id(PredLabel, ProcId, MaybeSeqNum, mangle_il, Id).

I suggest calling that `predlabel_to_il_id' rather than `predlabel_to_id'.
The rest looks fine.

Julien.
--------------------------------------------------------------------------
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