D-Programming-Language/dmd — pull request #3904 by IgorStepanov (2014-08-26 20:10:07+00:00)
Title: [new AA] aaLiteral + aaNew version

This PR depends on D-Programming-Language/druntime#933
This PR based on #3892, however in use zero AA init value.
I think, this way more pretty and safe.
New AA implemetation use template `object.aaLiteral` function to create AA.
This implemetation allows to return AA literals from CTFE, if `object.aaLiteral` can be evaluated at compile time. New aa implementation (D-Programming-Language/druntime#934) allow creating instances of AA at compile time (of cource, if hashes is CTFEable, and elements are eveluatable at compile time).
Template-based way implementation prevent using TypeInfo-based code, thus we need to know static Key and Value types to create AA instance.
As I said, this AA implementation doesn't use special initializer and empty AA like `int[int] aa;` doen't know his static type.
When we try to insert value in AA, compiler generates call of a special function : `aaGetX`:
Thereat I was need to introduce special helper function: `void *aaNew(Key, Value)();`
This function can be defined in `object`, and if it defined, when compiler generates `aaGetX` call, in pass pointer to `aaNew!(Key, Value)` to `aaGetX` and `aaGetX` can take this function and use in to initialize empty AA.
If `aaNew` doesn't defined, compiler doesn't pass any function to `aaGetX` (for compatibility with old AA implementation).
This solution causes a few small behaviour changes:
`test/runnable/imports/link12144a.d`:
If struct uses as AA key, `opEquals` should take const this and rvl. Same for `toHash`. Also we need to satisfy function promises like `pure` or `nothrow`. For example, we can not to create AA literal with key, with non-nothrow `toHash` in nothrow code. This is not breakage, this is partial fix of typesystem hole.

`test/runnable/test13117.d`:
`test/runnable/test13117b.d`:
exe-size can be larger then early, because new AA use templates.

`test/runnable/sdtor.d`:
`test/runnable/testaa.d`:
`test/runnable/testaa2.d`:
New implenetation calls postblit for keys (as needed), and may calls excess postblit in aa literal (because D hasn't rvalue-ref yet).