]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/d/dmd/root/object.h
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / gcc / d / dmd / root / object.h
1
2 /* Copyright (C) 1999-2018 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 #define POSIX (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun)
10
11 #pragma once
12
13 #include <stddef.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 };
30
31 /*
32 * Root of our class library.
33 */
34 class RootObject
35 {
36 public:
37 RootObject() { }
38
39 virtual bool equals(RootObject *o);
40
41 /**
42 * Return <0, ==0, or >0 if this is less than, equal to, or greater than obj.
43 * Useful for sorting Objects.
44 */
45 virtual int compare(RootObject *obj);
46
47 /**
48 * Pretty-print an Object. Useful for debugging the old-fashioned way.
49 */
50 virtual void print();
51
52 virtual const char *toChars();
53 virtual void toBuffer(OutBuffer *buf);
54
55 /**
56 * Used as a replacement for dynamic_cast. Returns a unique number
57 * defined by the library user. For Object, the return value is 0.
58 */
59 virtual int dyncast() const;
60 };