dmd AST class hierarchy as dot file

Guillaume Chatelet via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 20 11:20:03 PDT 2015


On Sunday, 20 September 2015 at 17:46:33 UTC, David Nadlinger 
wrote:
>
> which is not how the AST class hierarchy in the compiler looks.
>
> This is not to say that having pretty pictures for both of them 
> can't be useful. However, you seemed to assume that the 
> GraphViz file by Guillaume represented the grammar structure, 
> and I wanted to point out that it does not (at least not 
> directly).
>
>  — David

Yes this is pretty dmd specific but since I'm trying (again) to 
fix linux/OSX CPP name mangling I need a comprehensive 
description of dmd's internals.

I'm also not convinced this is currently achievable. eg.

template<typename A, typename B> void foo(A, B) {};
template void foo<int, int>(int, int); // mangled as 
_Z3fooIiiEvT_T0_

This template instantiation is mangled as `_Z3fooIiiEvT_T0_`.
First argument type is substituted with T_ (ie. first int which 
is encoded i in the function).
Second argument type is substituted with T0_ (ie. second int 
which is encoded i in the function).

dmd's internal will not create two different objects to represent 
the type int. So when encoding the argument types you have int 
and you can't know which one it is. Walter, if you have any idea 
:) I'm still struggling to understand the semantic of the fields 
of all the AST types.

This is important because is you reverse the arguments, then the 
type is mangled as `_Z3fooIiiEvT0_T_` (Note the inversion of T_ 
and T0_).

template<typename A, typename B> void foo(B, A) {};
template void foo<int, int>(int, int); // mangled as 
_Z3fooIiiEvT0_T_




More information about the Digitalmars-d mailing list