| 1 |
|
| 2 |
/* Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved |
| 3 |
* written by Walter Bright |
| 4 |
* https://www.digitalmars.com |
| 5 |
* Distributed under the Boost Software License, Version 1.0. |
| 6 |
* https://www.boost.org/LICENSE_1_0.txt |
| 7 |
* https://github.com/dlang/dmd/blob/master/src/dmd/rootobject.h |
| 8 |
*/ |
| 9 |
|
| 10 |
#pragma once |
| 11 |
|
| 12 |
#include "root/dsystem.h" |
| 13 |
#include "root/dcompat.h" |
| 14 |
|
| 15 |
typedef size_t hash_t; |
| 16 |
|
| 17 |
struct OutBuffer; |
| 18 |
|
| 19 |
enum DYNCAST |
| 20 |
{ |
| 21 |
DYNCAST_OBJECT, |
| 22 |
DYNCAST_EXPRESSION, |
| 23 |
DYNCAST_DSYMBOL, |
| 24 |
DYNCAST_TYPE, |
| 25 |
DYNCAST_IDENTIFIER, |
| 26 |
DYNCAST_TUPLE, |
| 27 |
DYNCAST_PARAMETER, |
| 28 |
DYNCAST_STATEMENT, |
| 29 |
DYNCAST_CONDITION, |
| 30 |
DYNCAST_TEMPLATEPARAMETER, |
| 31 |
DYNCAST_INITIALIZER |
| 32 |
}; |
| 33 |
|
| 34 |
/* |
| 35 |
* Root of our class library. |
| 36 |
*/ |
| 37 |
class RootObject |
| 38 |
{ |
| 39 |
public: |
| 40 |
RootObject() { } |
| 41 |
|
| 42 |
virtual bool equals(const RootObject * const o) const; |
| 43 |
|
| 44 |
/** |
| 45 |
* Pretty-print an Object. Useful for debugging the old-fashioned way. |
| 46 |
*/ |
| 47 |
virtual const char *toChars() const; |
| 48 |
/// This function is `extern(D)` and should not be called from C++, |
| 49 |
/// as the ABI does not match on some platforms |
| 50 |
virtual DString toString(); |
| 51 |
|
| 52 |
/** |
| 53 |
* Used as a replacement for dynamic_cast. Returns a unique number |
| 54 |
* defined by the library user. For Object, the return value is 0. |
| 55 |
*/ |
| 56 |
virtual DYNCAST dyncast() const; |
| 57 |
}; |