Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
object.di: Rename TypeInfo_Const.next to TypeInfo_Const.base.
Browse files Browse the repository at this point in the history
This is used e.g. in rt.lifetime, function unqualify.
  • Loading branch information
redstar committed Apr 11, 2015
1 parent ba7f253 commit 6abf8f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/object.di
Expand Up @@ -257,7 +257,7 @@ class TypeInfo_Tuple : TypeInfo

class TypeInfo_Const : TypeInfo
{
TypeInfo next;
TypeInfo base;
}

class TypeInfo_Invariant : TypeInfo_Const
Expand Down
2 changes: 1 addition & 1 deletion src/object_.d
Expand Up @@ -1225,7 +1225,7 @@ class TypeInfo_Const : TypeInfo
override @property size_t tsize() nothrow pure const { return base.tsize; }
override void swap(void *p1, void *p2) const { return base.swap(p1, p2); }

override @property inout(TypeInfo) next() nothrow pure inout { return base.next; }
override @property inout(TypeInfo) next() nothrow pure inout { return base; }
override @property uint flags() nothrow pure const { return base.flags; }
override const(void)[] init() nothrow pure const { return base.init(); }

Expand Down
11 changes: 1 addition & 10 deletions src/rt/aaA.d
Expand Up @@ -694,16 +694,7 @@ const(TypeInfo_AssociativeArray) _aaUnwrapTypeInfo(const(TypeInfo) tiRaw) pure n
break;

if (auto tiConst = cast(TypeInfo_Const)*p) {
// The member in object_.d and object.di differ. This is to ensure
// the file can be compiled both independently in unittest and
// collectively in generating the library. Fixing object.di
// requires changes to std.format in Phobos, fixing object_.d
// makes Phobos's unittest fail, so this hack is employed here to
// avoid irrelevant changes.
static if (is(typeof(&tiConst.base) == TypeInfo*))
p = &tiConst.base;
else
p = &tiConst.next;
p = &tiConst.base;
} else
assert(0); // ???
}
Expand Down
28 changes: 14 additions & 14 deletions src/rt/lifetime.d
Expand Up @@ -634,7 +634,7 @@ extern(C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) /+nothrow+/
// note, we do not care about shared. We are setting the length no matter
// what, so no lock is required.
debug(PRINTF) printf("_d_arrayshrinkfit, elemsize = %d, arr.ptr = x%x arr.length = %d\n", ti.next.tsize, arr.ptr, arr.length);
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto size = tinext.tsize; // array element size
auto cursize = arr.length * size;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
Expand Down Expand Up @@ -721,7 +721,7 @@ body
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
auto bic = isshared ? null : __getBlkInfo((*p).ptr);
auto info = bic ? *bic : GC.query((*p).ptr);
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto size = tinext.tsize;
version (D_InlineAsm_X86)
{
Expand Down Expand Up @@ -879,7 +879,7 @@ Lcontinue:
*/
extern (C) void[] _d_newarrayU(const TypeInfo ti, size_t length) pure nothrow
{
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto size = tinext.tsize;

debug(PRINTF) printf("_d_newarrayU(length = x%x, size = %d)\n", length, size);
Expand Down Expand Up @@ -939,7 +939,7 @@ Lcontinue:
extern (C) void[] _d_newarrayT(const TypeInfo ti, size_t length) pure nothrow
{
void[] result = _d_newarrayU(ti, length);
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto size = tinext.tsize;

memset(result.ptr, 0, size * length);
Expand All @@ -954,7 +954,7 @@ extern (C) void[] _d_newarrayiT(const TypeInfo ti, size_t length) pure nothrow
import core.internal.traits : TypeTuple;

void[] result = _d_newarrayU(ti, length);
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto size = tinext.tsize;

auto init = tinext.init();
Expand Down Expand Up @@ -990,7 +990,7 @@ void[] _d_newarrayOpT(alias op)(const TypeInfo ti, size_t[] dims)

void[] foo(const TypeInfo ti, size_t[] dims)
{
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto dim = dims[0];

debug(PRINTF) printf("foo(ti = %p, ti.next = %p, dim = %d, ndims = %d\n", ti, ti.next, dim, dims.length);
Expand Down Expand Up @@ -1472,7 +1472,7 @@ body
newdata = (*p).ptr;
return newdata[0 .. newlength];
}
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
size_t sizeelem = tinext.tsize;
version (D_InlineAsm_X86)
{
Expand Down Expand Up @@ -1638,7 +1638,7 @@ in
body
{
void* newdata;
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto sizeelem = tinext.tsize;
auto initializer = tinext.init();
auto initsize = initializer.length;
Expand Down Expand Up @@ -1828,7 +1828,7 @@ Loverflow:
extern (C) void[] _d_arrayappendT(const TypeInfo ti, ref byte[] x, byte[] y)
{
auto length = x.length;
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto sizeelem = tinext.tsize; // array element size
_d_arrayappendcTX(ti, x, y.length);
memcpy(x.ptr + length * sizeelem, y.ptr, y.length * sizeelem);
Expand Down Expand Up @@ -1930,7 +1930,7 @@ byte[] _d_arrayappendcTX(const TypeInfo ti, ref byte[] px, size_t n)
// This is a cut&paste job from _d_arrayappendT(). Should be refactored.

// only optimize array append where ti is not a shared type
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto sizeelem = tinext.tsize; // array element size
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
auto bic = isshared ? null : __getBlkInfo(px.ptr);
Expand Down Expand Up @@ -2110,7 +2110,7 @@ extern (C) void[] _d_arrayappendwd(ref byte[] x, dchar c)
extern (C) byte[] _d_arraycatT(const TypeInfo ti, byte[] x, byte[] y)
out (result)
{
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto sizeelem = tinext.tsize; // array element size
debug(PRINTF) printf("_d_arraycatT(%d,%p ~ %d,%p sizeelem = %d => %d,%p)\n", x.length, x.ptr, y.length, y.ptr, sizeelem, result.length, result.ptr);
assert(result.length == x.length + y.length);
Expand Down Expand Up @@ -2146,7 +2146,7 @@ body
return y;
}

auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto sizeelem = tinext.tsize; // array element size
debug(PRINTF) printf("_d_arraycatT(%d,%p ~ %d,%p sizeelem = %d)\n", x.length, x.ptr, y.length, y.ptr, sizeelem);
size_t xlen = x.length * sizeelem;
Expand Down Expand Up @@ -2176,7 +2176,7 @@ body
extern (C) void[] _d_arraycatnTX(const TypeInfo ti, byte[][] arrs)
{
size_t length;
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto size = tinext.tsize; // array element size

foreach(b; arrs)
Expand Down Expand Up @@ -2214,7 +2214,7 @@ extern (C) void[] _d_arraycatnTX(const TypeInfo ti, byte[][] arrs)
extern (C)
void* _d_arrayliteralTX(const TypeInfo ti, size_t length)
{
auto tinext = unqualify(ti.next);
auto tinext = unqualify(unqualify(ti).next);
auto sizeelem = tinext.tsize; // array element size
void* result;

Expand Down

0 comments on commit 6abf8f6

Please sign in to comment.