Re: Need DMD AST expertise

2016-06-21 Thread Guillaume Chatelet via Digitalmars-d
On Tuesday, 21 June 2016 at 19:42:54 UTC, Elie Morisse wrote: On Monday, 20 June 2016 at 20:52:02 UTC, Guillaume Chatelet wrote: [...] The templated function is the child symbol of the TemplateDeclaration which shares the same name i.e [...] Thx Elie! It helps :) I came up with this

Re: Need DMD AST expertise

2016-06-21 Thread Elie Morisse via Digitalmars-d
On Tuesday, 21 June 2016 at 19:42:54 UTC, Elie Morisse wrote: On Monday, 20 June 2016 at 20:52:02 UTC, Guillaume Chatelet wrote: « (cast(TypeFunction) fd->type)->parameters » Mixing C++ and D once more..

Re: Need DMD AST expertise

2016-06-21 Thread Elie Morisse via Digitalmars-d
On Monday, 20 June 2016 at 20:52:02 UTC, Guillaume Chatelet wrote: I'll have a look at `parameters` from TemplateDeclaration [2] but I still need to match it to the function arguments somehow. The templated function is the child symbol of the TemplateDeclaration which shares the same name i.e

Re: Need DMD AST expertise

2016-06-21 Thread Guillaume Chatelet via Digitalmars-d
On Tuesday, 21 June 2016 at 09:13:26 UTC, Jacob Carlborg wrote: On 2016-06-21 09:45, Guillaume Chatelet wrote: AFAIK basic types are instantiated once and reused: https://github.com/dlang/dmd/blob/b67694a0d74437d3a1581da2b9f1b785dc7b3c88/src/mtype.d#L861 So comparing pointers wouldn't work.

Re: Need DMD AST expertise

2016-06-21 Thread Jacob Carlborg via Digitalmars-d
On 2016-06-21 09:45, Guillaume Chatelet wrote: AFAIK basic types are instantiated once and reused: https://github.com/dlang/dmd/blob/b67694a0d74437d3a1581da2b9f1b785dc7b3c88/src/mtype.d#L861 So comparing pointers wouldn't work. Yeah. I'm just guessing here :). Sorry, I don't think I can

Re: Need DMD AST expertise

2016-06-21 Thread Guillaume Chatelet via Digitalmars-d
On Tuesday, 21 June 2016 at 06:25:26 UTC, Jacob Carlborg wrote: On 2016-06-20 22:52, Guillaume Chatelet wrote: [...] A guess: "tiargs" is the types of the values passed to the template. "tdtypes" is the types the template is instantiated with. void foo(T)(T* a); int b; foo!(int)(*);

Re: Need DMD AST expertise

2016-06-21 Thread Jacob Carlborg via Digitalmars-d
On 2016-06-20 22:52, Guillaume Chatelet wrote: The TemplateInstance [1] gives me `tiargs` and `tdtypes`. // Array of Types/Expressions of template // instance arguments [int*, char, 10*10] Objects* tiargs; // Array of Types/Expressions corresponding // to

Re: Need DMD AST expertise

2016-06-20 Thread Guillaume Chatelet via Digitalmars-d
On Monday, 20 June 2016 at 18:59:09 UTC, Jacob Carlborg wrote: On 2016-06-20 14:33, Guillaume Chatelet wrote: 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);

Re: Need DMD AST expertise

2016-06-20 Thread Jacob Carlborg via Digitalmars-d
On 2016-06-20 14:33, Guillaume Chatelet wrote: 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_");

Re: Need DMD AST expertise

2016-06-20 Thread Johan Engelen via Digitalmars-d
On Monday, 20 June 2016 at 14:06:57 UTC, Guillaume Chatelet wrote: Thx Johan. I'm confused though Sorry for misreading your question.

Re: Need DMD AST expertise

2016-06-20 Thread Guillaume Chatelet via Digitalmars-d
On Monday, 20 June 2016 at 14:42:22 UTC, Jacob Carlborg wrote: On 2016-06-20 16:06, Guillaume Chatelet wrote: Thx Johan. I'm confused though: `FuncDeclaration.linkage` is the linkage for the function (which I already know is C++ function since I'm mangling it) but I need the linkage for the

Re: Need DMD AST expertise

2016-06-20 Thread Jacob Carlborg via Digitalmars-d
On 2016-06-20 16:06, Guillaume Chatelet wrote: Thx Johan. I'm confused though: `FuncDeclaration.linkage` is the linkage for the function (which I already know is C++ function since I'm mangling it) but I need the linkage for the Parameter. Parameter has a Type but I can't get the linkage from

Re: Need DMD AST expertise

2016-06-20 Thread Guillaume Chatelet via Digitalmars-d
On Monday, 20 June 2016 at 13:50:45 UTC, Johan Engelen wrote: On Monday, 20 June 2016 at 12:33:31 UTC, Guillaume Chatelet wrote: class Expression; extern(C++) void foo(Expression); Question: - - How to I get the linkage for Expression from a FunDeclaration? This will ensure the

Re: Need DMD AST expertise

2016-06-20 Thread Johan Engelen via Digitalmars-d
On Monday, 20 June 2016 at 12:33:31 UTC, Guillaume Chatelet wrote: 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++

Need DMD AST expertise

2016-06-20 Thread Guillaume Chatelet via Digitalmars-d
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++