Skip to content

Comments

name mangling: bring documentation closer to actual implementation#1511

Merged
MartinNowak merged 1 commit intodlang:masterfrom
rainers:fix_mangle_spec
Dec 10, 2016
Merged

name mangling: bring documentation closer to actual implementation#1511
MartinNowak merged 1 commit intodlang:masterfrom
rainers:fix_mangle_spec

Conversation

@rainers
Copy link
Member

@rainers rainers commented Nov 5, 2016

This documents what I found in the current implementation. Not everything seems desirable, though...

Copy link
Member

@MartinNowak MartinNowak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

$(GNAME SymbolName):
$(B 0) $(GREEN // anonymous symbols)
$(GLINK LName)
$(GLINK TemplateInstanceName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move the less common anonymous symbol case to the bottom.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amended.

BTW: I've only seen this with overload sets as template arguments, but it looks like a bug to me: the overloaded symbol has these anonymous parents, but something like the location of the lookup should be encoded instead.

@MartinNowak MartinNowak merged commit 2b82e12 into dlang:master Dec 10, 2016
@wilzbach
Copy link
Contributor

@rainers: how about linking to the bison spec file that you curated? I imagine that this could help other people as well (at least those reading the spec about name mangling)

@rainers
Copy link
Member Author

rainers commented Dec 16, 2016

@wilzbach A bison grammar matching the documentation is now here: https://gist.githubusercontent.com/rainers/6cdf73b48837defb9f88/raw/0028d4aed82b0abf2a5a32322398ebe4595903bb/dwebsite3.bison

Not sure where to place and link to it. I think it would have to be part of the dlang.org repository to have a chance of staying in sync.

BTW: It shows 2 ambiguities in the grammar:

  • 'M' can be scope both on the function itself or the first function argument.
  • Y can be the end of an function argument list or the beginning of the type of an Objective-C function argument.

@wilzbach
Copy link
Contributor

Not sure where to place and link to it. I think it would have to be part of the dlang.org repository to have a chance of staying in sync.

How about creating a new data or bison folder?
What is your opinion @CyberShadow?

@CyberShadow
Copy link
Member

CyberShadow commented Dec 19, 2016 via email

$(B V) $(GLINK Type) $(GLINK Value)
$(B S) $(GLINK LName)
$(B S) $(GLINK SymbolName)
$(B S) $(GLINK MangledName)
Copy link
Member

@ibuclaw ibuclaw Apr 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this should be QualifiedName / MangledName.

Example: https://github.com/dlang/phobos/blob/31e1b462d2311f9d8cecb33172b28eab587b255d/std/parallelism.d#L43-L77

Instantiates this symbol:

std.parallelism.Task!(run, real delegate(MapResult!(getTerm, Result), ulong, ulong) @system, MapResult!(getTerm, Result), ulong, ulong).Task.impl

Mangled as:

_D3std11parallelism301__T4TaskS213std11parallelism3runTDFS3std9algorithm9iteration91__T9MapResultS31_D8parallel4mainFZ7getTermMFiZeTS3std5range13__T4iotaTiTiZ4iotaFiiZ6ResultZ9MapResultmmZeTS3std9algorithm9iteration91__T9MapResultS31_D8parallel4mainFZ7getTermMFiZeTS3std5range13__T4iotaTiTiZ4iotaFiiZ6ResultZ9MapResultTmTmZ4Task4implFPvZv

Right at the beginning of the first template you have:

__T4TaskS213std11parallelism3run
           ^

Also, this cunningly forgets Bugzilla 3043 where symbol arguments are prefixed with their length.

The correct grammar should be:

         $(GNAME TemplateArgX):
            $(B T) $(GLINK Type)
            $(B V) $(GLINK Type) $(GLINK Value)
            $(B S) $(GLINK Number) $(GLINK QualifiedName)
            $(B S) $(GLINK Number) $(GLINK MangledName)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, noticed this too last night, see https://issues.dlang.org/show_bug.cgi?id=14591#c7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants