view test/assign.d @ 339:385a18242485 trunk

[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too! Fixed issues with slice initialization (!!!) of multidimensional static arrays. Attempt to fix issue with referencing nested 'this' pointers introduced in DMD 1.033 merge.
author lindquist
date Sun, 13 Jul 2008 01:29:49 +0200
parents c53b6e3fe49a
children
line wrap: on
line source

module assign;

// this is taken from std.intrinsic from gdc

int mybtc(uint *p, uint bitnum)
{
    uint * q = p + (bitnum / (uint.sizeof*8));
    uint mask = 1 << (bitnum & ((uint.sizeof*8) - 1));
    int result = *q & mask;
    *q ^= mask;
    return result ? -1 : 0;
}

void main()
{
    uint i = 0xFFFF_FFFF;
    int r = mybtc(&i, 31);
    assert(r);
    assert(i == 0x7FFF_FFFF);
    r = mybtc(&i, 31);
    assert(!r);
    assert(i == 0xFFFF_FFFF);
}