On 01/25/2011 08:54 AM, bearophile wrote:
Andrej Mitrovic:

It's interesting that enum works but immutable doesn't. enum will do, Thanks.

But there are some problems with enum AAs. Take a look at this little program:

enum int[int] aa = [1:2, 3:4];
int foo(int x) {
     return aa[x];
}
void main() {}


And the asm of foo():

_D4test3fooFiZi comdat
         push    EAX
         mov ECX,offset FLAT:_D10TypeInfo_i6__initZ
         mov EDX,offset FLAT:_D12TypeInfo_Hii6__initZ
         push    EAX
         push    4
         push    ECX
         push    4
         push    3
         push    2
         push    1
         push    2
         push    EDX
         call    near ptr __d_assocarrayliteralT
         add ESP,018h
         push    EAX
         call    near ptr __aaGetRvalue
         mov EAX,[EAX]
         add ESP,010h
         pop ECX
         ret

Bye,
bearophile

IIUC, the compiler re-defines the constant (enum) AA at use point. Why?

Denis
--
_________________
vita es estrany
spir.wikidot.com

Reply via email to