non-constant error for module AA"s

bearophile bearophileHUGS at lycos.com
Mon Jan 24 23:54:01 PST 2011


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


More information about the Digitalmars-d-learn mailing list