mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 05:30:13 +03:00
Merge pull request #6745 from yebblies/cppmanglert
Let Target determine how to mangle extern(C++) symbols merged-on-behalf-of: Iain Buclaw <ibuclaw@gdcproject.org>
This commit is contained in:
commit
2cc58d9b0e
4 changed files with 1697 additions and 1682 deletions
|
@ -37,8 +37,7 @@ import ddmd.visitor;
|
|||
* ABI has no concept of. These affect every D mangled name,
|
||||
* so nothing would be compatible anyway.
|
||||
*/
|
||||
static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)
|
||||
{
|
||||
|
||||
/*
|
||||
* Follows Itanium C++ ABI 1.86
|
||||
*/
|
||||
|
@ -922,22 +921,20 @@ static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TAR
|
|||
}
|
||||
}
|
||||
|
||||
extern (C++) const(char)* toCppMangle(Dsymbol s)
|
||||
extern (C++) const(char)* toCppMangleItanium(Dsymbol s)
|
||||
{
|
||||
//printf("toCppMangle(%s)\n", s.toChars());
|
||||
//printf("toCppMangleItanium(%s)\n", s.toChars());
|
||||
scope CppMangleVisitor v = new CppMangleVisitor();
|
||||
return v.mangleOf(s);
|
||||
}
|
||||
|
||||
extern (C++) const(char)* cppTypeInfoMangle(Dsymbol s)
|
||||
extern (C++) const(char)* cppTypeInfoMangleItanium(Dsymbol s)
|
||||
{
|
||||
//printf("cppTypeInfoMangle(%s)\n", s.toChars());
|
||||
scope CppMangleVisitor v = new CppMangleVisitor();
|
||||
return v.mangle_typeinfo(s);
|
||||
}
|
||||
}
|
||||
else static if (TARGET_WINDOS)
|
||||
{
|
||||
|
||||
// Windows DMC and Microsoft Visual C++ mangling
|
||||
enum VC_SAVED_TYPE_CNT = 10u;
|
||||
enum VC_SAVED_IDENT_CNT = 10u;
|
||||
|
@ -1962,19 +1959,14 @@ else static if (TARGET_WINDOS)
|
|||
}
|
||||
}
|
||||
|
||||
extern (C++) const(char)* toCppMangle(Dsymbol s)
|
||||
extern (C++) const(char)* toCppMangleMSVC(Dsymbol s)
|
||||
{
|
||||
scope VisualCPPMangler v = new VisualCPPMangler(!global.params.mscoff);
|
||||
return v.mangleOf(s);
|
||||
}
|
||||
|
||||
extern (C++) const(char)* cppTypeInfoMangle(Dsymbol s)
|
||||
extern (C++) const(char)* cppTypeInfoMangleMSVC(Dsymbol s)
|
||||
{
|
||||
//printf("cppTypeInfoMangle(%s)\n", s.toChars());
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static assert(0, "fix this");
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import ddmd.id;
|
|||
import ddmd.mtype;
|
||||
import ddmd.root.ctfloat;
|
||||
import ddmd.root.outbuffer;
|
||||
import ddmd.target;
|
||||
import ddmd.utf;
|
||||
import ddmd.visitor;
|
||||
|
||||
|
@ -451,7 +452,7 @@ public:
|
|||
buf.writestring(d.ident.toChars());
|
||||
return;
|
||||
case LINKcpp:
|
||||
buf.writestring(toCppMangle(d));
|
||||
buf.writestring(Target.toCppMangle(d));
|
||||
return;
|
||||
case LINKdefault:
|
||||
d.error("forward declaration");
|
||||
|
|
|
@ -10,7 +10,10 @@
|
|||
|
||||
module ddmd.target;
|
||||
|
||||
import ddmd.cppmangle;
|
||||
import ddmd.dclass;
|
||||
import ddmd.dmodule;
|
||||
import ddmd.dsymbol;
|
||||
import ddmd.expression;
|
||||
import ddmd.globals;
|
||||
import ddmd.identifier;
|
||||
|
@ -429,6 +432,25 @@ struct Target
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
extern (C++) static const(char)* toCppMangle(Dsymbol s)
|
||||
{
|
||||
static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)
|
||||
return toCppMangleItanium(s);
|
||||
else static if (TARGET_WINDOS)
|
||||
return toCppMangleMSVC(s);
|
||||
else
|
||||
static assert(0, "fix this");
|
||||
}
|
||||
extern (C++) static const(char)* cppTypeInfoMangle(ClassDeclaration cd)
|
||||
{
|
||||
static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)
|
||||
return cppTypeInfoMangleItanium(cd);
|
||||
else static if (TARGET_WINDOS)
|
||||
return cppTypeInfoMangleMSVC(cd);
|
||||
else
|
||||
static assert(0, "fix this");
|
||||
}
|
||||
}
|
||||
|
||||
/******************************
|
||||
|
|
|
@ -777,7 +777,7 @@ Symbol* toSymbolCpp(ClassDeclaration cd)
|
|||
*/
|
||||
Symbol *toSymbolCppTypeInfo(ClassDeclaration cd)
|
||||
{
|
||||
const id = cppTypeInfoMangle(cd);
|
||||
const id = Target.cppTypeInfoMangle(cd);
|
||||
auto s = symbol_calloc(id, cast(uint)strlen(id));
|
||||
s.Sclass = SCextern;
|
||||
s.Sfl = FLextern; // C++ code will provide the definition
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue