1 /* Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved 2 * http://www.digitalmars.com 3 * Distributed under the Boost Software License, Version 1.0. 4 * (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) 5 * https://github.com/D-Programming-Language/dmd/blob/master/src/root/object.c 6 */ 7 8 #include "dsystem.h" 9 #include "object.h" 10 #include "outbuffer.h" 11 12 /****************************** Object ********************************/ 13 equals(RootObject * o)14bool RootObject::equals(RootObject *o) 15 { 16 return o == this; 17 } 18 compare(RootObject * obj)19int RootObject::compare(RootObject *obj) 20 { 21 size_t lhs = (size_t)this; 22 size_t rhs = (size_t)obj; 23 if (lhs < rhs) 24 return -1; 25 else if (lhs > rhs) 26 return 1; 27 return 0; 28 } 29 print()30void RootObject::print() 31 { 32 printf("%s %p\n", toChars(), this); 33 } 34 toChars()35const char *RootObject::toChars() 36 { 37 return "Object"; 38 } 39 dyncast()40int RootObject::dyncast() const 41 { 42 return DYNCAST_OBJECT; 43 } 44 toBuffer(OutBuffer * b)45void RootObject::toBuffer(OutBuffer *b) 46 { 47 b->writestring("Object"); 48 } 49