1 /** 2 * Provide the root object that classes in dmd inherit from. 3 * 4 * Copyright: Copyright (C) 1999-2020 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 10 */ 11 12 module dmd.root.rootobject; 13 14 import core.stdc.stdio; 15 16 import dmd.root.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 } 34 35 /*********************************************************** 36 */ 37 38 extern (C++) class RootObject 39 { 40 this() nothrow pure @nogc @safe 41 { 42 } 43 44 bool equals(const RootObject o) const 45 { 46 return o is this; 47 } 48 49 const(char)* toChars() const 50 { 51 assert(0); 52 } 53 54 /// 55 extern(D) const(char)[] toString() const 56 { 57 import core.stdc.string : strlen; 58 auto p = this.toChars(); 59 return p[0 .. strlen(p)]; 60 } 61 62 DYNCAST dyncast() const nothrow pure @nogc @safe 63 { 64 return DYNCAST.object; 65 } 66 }