Need DMD AST expertise

Guillaume Chatelet via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 20 05:33:31 PDT 2016


Context:

I'm working on a more correct implementation of the C++ name 
mangling for Linux/OSX. This is needed for the integration with 
C++/STL.

------------------------------------------------------------

Problem 1:
----------
In the following D code 'Expression' is a D class, 'foo' is a C++ 
function, its argument must be mangled as a pointer to Expression 
because D has reference semantic (whereas C++ has value semantic).

> class Expression;
> extern(C++) void foo(Expression);

Question:
---------
- How to I get the linkage for Expression from a FunDeclaration? 
This will ensure the added indirection is put only for the D 
classes, not the C++ ones. I tried looking at Parameter, 
ClassDeclaration or TypeClass but couldn't find it.

------------------------------------------------------------

Problem 2:
----------
Template arguments that are of basic types are mangled in a 
special way which requires to understand which 'int' is which.

> extern(C++) A foo(A, B)(B, A, B);
> static assert(foo!(int,int).mangleof == 
> "_Z3fooIiiET_T0_S0_S1_");

In the example above the first 'int' is not the same as the 
second one, it's a distinct substitution.

Question:
---------
- How can I know which is which since from the AST perspective, 
the FunDeclaration's Parameters are just TypeBasic 'int'?

------------------------------------------------------------

Thx in advance!


More information about the Digitalmars-d mailing list