[dmd-internals] AAs in the dmd backend

Robert Clipsham robert at octarineparrot.com
Wed Mar 31 19:33:56 PDT 2010


Hi there,

I'm working on a patch for 
http://d.puremagic.com/issues/show_bug.cgi?id=3987 and have figured out 
all the details of why debugging with function pointers isn't working, I 
need to make sure I implement the fix properly so it gets accepted 
though... I'm in need of an associative array, what is the correct way 
to do this in the dmd backend?

The exact issue is that the .debug_info for function pointers isn't 
cached, so unlike the basic types the info is generated again, and 
breaks by writing out the debug info in the middle of the current 
function pointer (if that makes sense). So with the following:

T function(U function(V)) foobar;

The debug info is generated recursively, then the debug info for V is 
output, then U, then the function pointer etc etc. When it gets to 
writing the debug info for T function() though, it tries to generate the 
debug info for its parameters. For basic types this is cached in the 
typidx_tab array, so it pulls out the reference and places that in, 
however for function pointers it generates it again, so you end up 
mixing up the debug order. To fix this I need a way to cache function 
pointers, the obvious way to do this seems to be with an AA (I'd also 
need to find a way to mangle a given function pointers type, probably by 
recurring through it). What would be the right way to go about this? 
Should I use an AA, and if so, what is the preferred way to do this in 
the DMDBE? If not, how would you recommend I go about this?

Thanks,

Robert



More information about the dmd-internals mailing list