On Tuesday, 23 December 2014 at 11:53:38 UTC, Dicebot wrote:


By upstream I don't mean LDC upstream but D upstream - we don't want it to become part of full language spec if implementation is so reliable on specific toolchain. It has been already discussed when Jacob proposed dstep integration AFAIR.

Actually it's meant to be optional and Calypso should ultimately go in a separate shared library.

As I implemented it I added this virtual function to Dsymbol:

   virtual LangPlugin *langPlugin() { return NULL; }

The import (C++) create cpp::****Decl which derive from the DMD ****Decl and override some of its parent methods. E.g:

   bool isBaseOf(::ClassDeclaration* cd, int* poffset) override;

makes isBaseOf take into account multiple inheritance and ask Clang to compute the right offsets.

Then in gen/, there is a different kind of hook which checks if a langPlugin is attached to the declaration:

   if (auto lp = s->langPlugin()) // yeah C++11, it's a prototype
     return lp->codeGen()->toCallFunction(s, ...);

And that way neither DMD nor LDC has to depend on Clang. The intrusions are the methods made virtual and the hooks, but if no language extension is present LDC would work as usual.

Reply via email to