Home | History | Annotate | Line # | Download | only in root
      1 
      2 /* Copyright (C) 1999-2022 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/root/object.h
      8  */
      9 
     10 #pragma once
     11 
     12 #include "dsystem.h"
     13 #include "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_TEMPLATEPARAMETER
     30 };
     31 
     32 /*
     33  * Root of our class library.
     34  */
     35 class RootObject
     36 {
     37 public:
     38     RootObject() { }
     39 
     40     virtual bool equals(const RootObject *o) const;
     41 
     42     /**
     43      * Pretty-print an Object. Useful for debugging the old-fashioned way.
     44      */
     45     virtual const char *toChars() const;
     46     /// This function is `extern(D)` and should not be called from C++,
     47     /// as the ABI does not match on some platforms
     48     virtual DString toString();
     49 
     50     /**
     51      * Used as a replacement for dynamic_cast. Returns a unique number
     52      * defined by the library user. For Object, the return value is 0.
     53      */
     54     virtual DYNCAST dyncast() const;
     55 };
     56