digitalmars.D - Using symbol for instance variable offset
- Jacob Carlborg (26/26) Mar 31 2014 As a part of implementing D/Ob...
As a part of implementing D/Objective-C I need to implement non-fragile instance variables for 64bit. Non-fragile instance variables work like regular instance variables except that instead of using a compile time known offset, a symbol containing the offset is used. The compiler outputs these symbols with the compile time known offset. Then at load time the offset can be replaced with something else. At runtime when accessing an instance variable the offset stored in the symbol should be used. I hit a problem trying to implement this. This is how the implementation currently looks like . If I output the offset symbol for an instance variable in DotVarExp::toElem  I get a duplicate symbol error when compiling an application. If I don't output the offset symbol I get an assertion failure here instead . Note that I'm currently always outputting the offset symbol when outputting the metadata for a class . Any ideas how to solve this?  https://github.com/jacob-carlborg/dmd/commit/9d9f6c9a5edc455b066ec77c5f1373b2886860a6  https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/e2ir.c#L3664-L3674  https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/backend/cod1.c#L1487  https://github.com/jacob-carlborg/dmd/blob/9d9f6c9a5edc455b066ec77c5f1373b2886860a6/src/objc.c#L1629 Note, the code is not up to date with upstream HEAD, but it's fairly recent. -- /Jacob Carlborg
Mar 31 2014