www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - :wq

reply "Iain Buclaw" <ibuclaw ubuntu.com> writes:
Given the code:

module mangle;

extern (C) bool runModuleUnitTests()
{
     static struct Console
     {
         Console opCall( in char[] val )
         {
             return this;
         }
     }
     return false;
}


The D frontend will generate the mangled symbol (and its 
initialiser) as:

_D6mangle18runModuleUnitTestsUZb7Console6opCallMFxAaZSrunModuleUnitTests7Console
_DrunModuleUnitTests7Console6__initZ

Instead of the more desired:

_D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS6mangle18runModuleUnitTestsFZb7Console
_D18runModuleUnitTest7Console6__initZ


Is this desirable? It makes demangling such symbols difficult.
Jan 02 2014
next sibling parent "Iain Buclaw" <ibuclaw ubuntu.com> writes:
On Thursday, 2 January 2014 at 17:38:30 UTC, Iain Buclaw wrote:
 _D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS6mangle18runModuleUnitTestsFZb7Console
That should be: _D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS18runModuleUnitTestsFZb7Console
Jan 02 2014
prev sibling parent reply Martin Nowak <code dawg.eu> writes:
On 01/02/2014 06:38 PM, Iain Buclaw wrote:
 The D frontend will generate the mangled symbol (and its initialiser) as:

 _D6mangle18runModuleUnitTestsUZb7Console6opCallMFxAaZSrunModuleUnitTests7Console

 _DrunModuleUnitTests7Console6__initZ

 Instead of the more desired:

 _D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS6mangle18runModuleUnitTestsFZb7Console

 _D18runModuleUnitTest7Console6__initZ


 Is this desirable? It makes demangling such symbols difficult.
I think we should ignore extern(C) when mangling nested symbols. But we should obey the calling convention. So according to http://dlang.org/abi.html it's UZb instead of FZb.
Jan 02 2014
parent Iain Buclaw <ibuclaw gdcproject.org> writes:
On 2 Jan 2014 19:50, "Martin Nowak" <code dawg.eu> wrote:
 On 01/02/2014 06:38 PM, Iain Buclaw wrote:
 The D frontend will generate the mangled symbol (and its initialiser) as:
_D6mangle18runModuleUnitTestsUZb7Console6opCallMFxAaZSrunModuleUnitTests7Console
 _DrunModuleUnitTests7Console6__initZ

 Instead of the more desired:
_D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS6mangle18runModuleUnitTestsFZb7Console
 _D18runModuleUnitTest7Console6__initZ


 Is this desirable? It makes demangling such symbols difficult.
I think we should ignore extern(C) when mangling nested symbols. But we should obey the calling convention. So according to http://dlang.org/abi.html it's UZb instead of FZb.
I should probably rewrite the message as I did it in an awful hurry. ;) The main point was getting across was that in the normal scheme of mangling it follows the convention in a nutshell: TypeStruct QualifiedSymbol (Int Symbol) ... Eg: S6foobar5inner... Should 'foobar' be an extern (C) function, then the initial string count is omitted. Sfoobar5inner Causing core.demangler to choke on it. This affects the demangler I've written for gdb as it follows the same rules to parse the mangled string.
Jan 02 2014