Skip to content

Commit 2ece573

Browse files
committed
Remove rt/cast_.d
1 parent 9ec2c0e commit 2ece573

File tree

3 files changed

+51
-87
lines changed

3 files changed

+51
-87
lines changed

druntime/mak/SRCS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ SRCS=\
565565
src\rt\adi.d \
566566
src\rt\alloca.d \
567567
src\rt\arraycat.d \
568-
src\rt\cast_.d \
569568
src\rt\cmath2.d \
570569
src\rt\config.d \
571570
src\rt\cover.d \

druntime/src/object.d

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,57 @@ class TypeInfo_Delegate : TypeInfo
15721572
}
15731573

15741574
private extern (C) Object _d_newclass(const TypeInfo_Class ci);
1575-
private extern (C) int _d_isbaseof(scope TypeInfo_Class child,
1576-
scope const TypeInfo_Class parent) @nogc nothrow pure @safe; // rt.cast_
1575+
1576+
extern(C) int _d_isbaseof(scope ClassInfo oc, scope const ClassInfo c) @nogc nothrow pure @safe
1577+
{
1578+
import core.internal.cast_ : areClassInfosEqual;
1579+
1580+
if (areClassInfosEqual(oc, c))
1581+
return true;
1582+
1583+
do
1584+
{
1585+
if (oc.base && areClassInfosEqual(oc.base, c))
1586+
return true;
1587+
1588+
// Bugzilla 2013: Use depth-first search to calculate offset
1589+
// from the derived (oc) to the base (c).
1590+
foreach (iface; oc.interfaces)
1591+
{
1592+
if (areClassInfosEqual(iface.classinfo, c) || _d_isbaseof(iface.classinfo, c))
1593+
return true;
1594+
}
1595+
1596+
oc = oc.base;
1597+
} while (oc);
1598+
1599+
return false;
1600+
}
1601+
1602+
/******************************************
1603+
* Given a pointer:
1604+
* If it is an Object, return that Object.
1605+
* If it is an interface, return the Object implementing the interface.
1606+
* If it is null, return null.
1607+
* Else, undefined crash
1608+
*/
1609+
extern(C) Object _d_toObject(return scope void* p) @nogc nothrow pure @trusted
1610+
{
1611+
if (!p)
1612+
return null;
1613+
1614+
Object o = cast(Object) p;
1615+
Interface* pi = **cast(Interface***) p;
1616+
1617+
/* Interface.offset lines up with ClassInfo.name.ptr,
1618+
* so we rely on pointers never being less than 64K,
1619+
* and Objects never being greater.
1620+
*/
1621+
if (pi.offset < 0x10000)
1622+
return cast(Object)(p - pi.offset);
1623+
1624+
return o;
1625+
}
15771626

15781627
/**
15791628
* Runtime type information about a class.

druntime/src/rt/cast_.d

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)