[m-rev.] for review: improve procname mangling for .NET backend.
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed May 9 14:43:37 AEST 2001
On 09-May-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> Index: compiler/mlds_to_il.m
...
> + %
> + % We mangle as follows:
> + % - Problem:
> + % Two preds or funcs with different arities in Mercury end
> + % up having the same types and arities in IL.
I suggest adding a bit more here to explain why that can happen, e.g.
% Two preds or funcs with different arities in Mercury end
% up having the same types and arities in IL, e.g. because
% one of them takes io__state arguments which get omitted
% in IL.
> + % - Problem:
> + % A semidet pred returns its success value, and so has
> + % the same return type (bool) as a function.
> + %
> + % To avoid this, we mangle all semidet preds and
> + % functions to include whether they are a pred or a
> + % function using _p or _f.
The spec is not clear here: do you mean to mangle all functions
or just semidet functions? The code below just mangles semidet
functions, but that's wrong, because the clash you're thinking of
here occurs when you have a det function and a semidet predicate, e.g.
:- func foo(int) = bool
:- pred foo(int::in) is semidet.
% both map to `bool foo_1(int)'
Anyway, to avoid a collision, you only need to mangle one of the two
clashing identifiers; so you could just mangle semidet preds, and leave
the functions alone. I think that would be a nicer approach.
However, there is another problem which you didn't mention.
The same thing can occur for predicates which are not semidet:
:- func foo(int::out) = (int::in) is det.
:- pred foo(int::out, int::in) is det.
% both map to `void foo_2(int &, int)'
That needs to be fixed.
> + % So the mangled name is:
> + % (<modulename>_)<procname>_<arity>(_f|_p)(_m<modenum>)(_i<seqnum>)
> + %
> + % Where parentheses indicate optional components.
> + %
> + % Since each optional component (except the modulename) is after
> + % the mandatory arity, and the components have unique prefixes,
> + % it isn't possible to generate names that conflict with user
> + % names.
I think that it may be possible to have conflicts with user names
in the case where there is a <modulename>. However, this is a minor
issue; it's probably OK to just XXX it for now.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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