Null references redux + Cyclone
Jeremie Pelletier
jeremiep at gmail.com
Tue Sep 29 07:32:59 PDT 2009
bearophile wrote:
> Walter Bright:
>
>> No, it is done with one indirection.<
>
> If even Andrei, a quite intelligent person that has written big books on C++, may be wrong on such a basic thing, then I think there's a problem.
>
> It can be good to create an html page that explains how some basic things of D are implemented in the front-end. Such page can also contain box & arrow images that show how structures and memory are organized for various of such data structures.
>
> Such html page is useful for both normal programmers that want to understand what's under the hood, and for people that may want to fix/modify the front-end.
>
> Bye,
> bearophile
I agree, the ABI documentation on digitalmars.com is far from complete,
I had to learn a lot of it through trial and error. What was especially
confusing was the interface reference vs the interface info vs the
interface's classinfo vs the referenced object, I wrote an internal
wrapper struct to make most of the casts go away:
struct Interface {
Object object() const {
return cast(Object)(cast(void*)&this - interfaceinfo.offset);
}
immutable(InterfaceInfo)* interfaceinfo() const {
return **cast(InterfaceInfo***)&this;
}
immutable(ClassInfo) classinfo() const {
return interfaceinfo.classinfo;
}
}
immutable struct InterfaceInfo {
ClassInfo classinfo;
void*[] vtbl;
ptrdiff_t offset;
}
These two made implementing D internals a whole lot easier! I think only
InterfaceInfo is in druntime (and its confusingly named Interface in there).
More information about the Digitalmars-d
mailing list