1 2/* Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved 3 * http://www.digitalmars.com 4 * Distributed under the Boost Software License, Version 1.0. 5 * (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) 6 * https://github.com/dlang/dmd/blob/master/src/root/object.h 7 */ 8 9#pragma once 10 11#include "dsystem.h" 12 13typedef size_t hash_t; 14 15struct OutBuffer; 16 17enum DYNCAST 18{ 19 DYNCAST_OBJECT, 20 DYNCAST_EXPRESSION, 21 DYNCAST_DSYMBOL, 22 DYNCAST_TYPE, 23 DYNCAST_IDENTIFIER, 24 DYNCAST_TUPLE, 25 DYNCAST_PARAMETER, 26 DYNCAST_STATEMENT 27}; 28 29/* 30 * Root of our class library. 31 */ 32class RootObject 33{ 34public: 35 RootObject() { } 36 37 virtual bool equals(RootObject *o); 38 39 /** 40 * Return <0, ==0, or >0 if this is less than, equal to, or greater than obj. 41 * Useful for sorting Objects. 42 */ 43 virtual int compare(RootObject *obj); 44 45 /** 46 * Pretty-print an Object. Useful for debugging the old-fashioned way. 47 */ 48 virtual void print(); 49 50 virtual const char *toChars(); 51 virtual void toBuffer(OutBuffer *buf); 52 53 /** 54 * Used as a replacement for dynamic_cast. Returns a unique number 55 * defined by the library user. For Object, the return value is 0. 56 */ 57 virtual int dyncast() const; 58}; 59