1 /** 2 * Provide the root object that classes in dmd inherit from. 3 * 4 * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved 5 * Authors: Walter Bright, https://www.digitalmars.com 6 * License: $(LINK2 https://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 10 */ 11 12 module dmd.root.rootobject; 13 14 import core.stdc.stdio; 15 16 import dmd.common.outbuffer; 17 18 /*********************************************************** 19 */ 20 21 enum DYNCAST : int 22 { 23 object, 24 expression, 25 dsymbol, 26 type, 27 identifier, 28 tuple, 29 parameter, 30 statement, 31 condition, 32 templateparameter, 33 initializer, 34 } 35 36 /*********************************************************** 37 */ 38 39 extern (C++) class RootObject 40 { 41 this() nothrow pure @nogc @safe scope 42 { 43 } 44 45 bool equals(const RootObject o) const 46 { 47 return o is this; 48 } 49 50 const(char)* toChars() const 51 { 52 assert(0); 53 } 54 55 /// 56 extern(D) const(char)[] toString() const 57 { 58 import core.stdc.string : strlen; 59 auto p = this.toChars(); 60 return p[0 .. strlen(p)]; 61 } 62 63 DYNCAST dyncast() const nothrow pure @nogc @safe 64 { 65 return DYNCAST.object; 66 } 67 }