Enable flate-combine.
[official-gcc.git] / gcc / d / dmd / enum.h
blob4e6fbe2cacfbb970a8bb7967b858f85182f5f625
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * https://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * https://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/dlang/dmd/blob/master/src/dmd/enum.h
9 */
11 #pragma once
13 #include "dsymbol.h"
14 #include "declaration.h"
16 class Identifier;
17 class Type;
18 class Expression;
20 namespace dmd
22 // in enumsem.d
23 Expression *getDefaultValue(EnumDeclaration *ed, const Loc &loc);
26 class EnumDeclaration final : public ScopeDsymbol
28 public:
29 /* The separate, and distinct, cases are:
30 * 1. enum { ... }
31 * 2. enum : memtype { ... }
32 * 3. enum id { ... }
33 * 4. enum id : memtype { ... }
34 * 5. enum id : memtype;
35 * 6. enum id;
37 Type *type; // the TypeEnum
38 Type *memtype; // type of the members
39 Visibility visibility;
41 Expression *maxval;
42 Expression *minval;
43 Expression *defaultval; // default initializer
44 private:
45 uint8_t bitFields;
46 public:
47 bool isdeprecated() const;
48 bool isdeprecated(bool v);
49 bool added() const;
50 bool added(bool v);
51 bool inuse() const;
52 bool inuse(bool v);
54 EnumDeclaration *syntaxCopy(Dsymbol *s) override;
55 bool oneMember(Dsymbol *&ps, Identifier *ident) override;
56 Type *getType() override;
57 const char *kind() const override;
58 bool isDeprecated() const override; // is Dsymbol deprecated?
59 Visibility visible() override;
60 bool isSpecial() const;
62 EnumDeclaration *isEnumDeclaration() override { return this; }
64 Symbol *sinit;
65 void accept(Visitor *v) override { v->visit(this); }
69 class EnumMember final : public VarDeclaration
71 public:
72 /* Can take the following forms:
73 * 1. id
74 * 2. id = value
75 * 3. type id = value
77 Expression *&value();
79 // A cast() is injected to 'value' after semantic(),
80 // but 'origValue' will preserve the original value,
81 // or previous value + 1 if none was specified.
82 Expression *origValue;
83 Type *origType;
85 EnumDeclaration *ed;
87 EnumMember *syntaxCopy(Dsymbol *s) override;
88 const char *kind() const override;
90 EnumMember *isEnumMember() override { return this; }
91 void accept(Visitor *v) override { v->visit(this); }