d: Merge dmd. druntime e770945277, phobos 6d6e0b9b9
[official-gcc.git] / gcc / d / dmd / enum.h
blob650bf3e2c7cdac7319b21bd22a478037ca103fb1
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 class EnumDeclaration final : public ScopeDsymbol
22 public:
23 /* The separate, and distinct, cases are:
24 * 1. enum { ... }
25 * 2. enum : memtype { ... }
26 * 3. enum id { ... }
27 * 4. enum id : memtype { ... }
28 * 5. enum id : memtype;
29 * 6. enum id;
31 Type *type; // the TypeEnum
32 Type *memtype; // type of the members
33 Visibility visibility;
35 Expression *maxval;
36 Expression *minval;
37 Expression *defaultval; // default initializer
38 private:
39 uint8_t bitFields;
40 public:
41 bool isdeprecated() const;
42 bool isdeprecated(bool v);
43 bool added() const;
44 bool added(bool v);
45 bool inuse() const;
46 bool inuse(bool v);
48 EnumDeclaration *syntaxCopy(Dsymbol *s) override;
49 bool oneMember(Dsymbol *&ps, Identifier *ident) override;
50 Type *getType() override;
51 const char *kind() const override;
52 bool isDeprecated() const override; // is Dsymbol deprecated?
53 Visibility visible() override;
54 bool isSpecial() const;
56 EnumDeclaration *isEnumDeclaration() override { return this; }
58 Symbol *sinit;
59 void accept(Visitor *v) override { v->visit(this); }
63 class EnumMember final : public VarDeclaration
65 public:
66 /* Can take the following forms:
67 * 1. id
68 * 2. id = value
69 * 3. type id = value
71 Expression *&value();
73 // A cast() is injected to 'value' after semantic(),
74 // but 'origValue' will preserve the original value,
75 // or previous value + 1 if none was specified.
76 Expression *origValue;
77 Type *origType;
79 EnumDeclaration *ed;
81 EnumMember *syntaxCopy(Dsymbol *s) override;
82 const char *kind() const override;
84 EnumMember *isEnumMember() override { return this; }
85 void accept(Visitor *v) override { v->visit(this); }