d: Merge upstream dmd 568496d5b, druntime 178c44ff, phobos 574bf883b.
[official-gcc.git] / gcc / d / dmd / root / rootobject.d
blob64104b823d1f0c36a3449c7837304e3f0583c8ec
1 /**
2 * Provide the root object that classes in dmd inherit from.
4 * Copyright: Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved
5 * Authors: Walter Bright, http://www.digitalmars.com
6 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
7 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/rootobject.d, root/_rootobject.d)
8 * Documentation: https://dlang.org/phobos/dmd_root_rootobject.html
9 * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/root/rootobject.d
12 module dmd.root.rootobject;
14 import core.stdc.stdio;
16 import dmd.common.outbuffer;
18 /***********************************************************
21 enum DYNCAST : int
23 object,
24 expression,
25 dsymbol,
26 type,
27 identifier,
28 tuple,
29 parameter,
30 statement,
31 condition,
32 templateparameter,
33 initializer,
36 /***********************************************************
39 extern (C++) class RootObject
41 this() nothrow pure @nogc @safe
45 bool equals(const RootObject o) const
47 return o is this;
50 const(char)* toChars() const
52 assert(0);
55 ///
56 extern(D) const(char)[] toString() const
58 import core.stdc.string : strlen;
59 auto p = this.toChars();
60 return p[0 .. strlen(p)];
63 DYNCAST dyncast() const nothrow pure @nogc @safe
65 return DYNCAST.object;