Redo of pull #1179

Redo of https://github.com/D-Programming-Language/dmd/pull/1179

I'm not terribly happy with the size of the generated files, but we'll see how it goes.