Debian Codegraph @

gcc/d/dmd/enum.h

raw
1
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2025 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 */
10
11 #pragma once
12
13 #include "dsymbol.h"
14 #include "declaration.h"
15
16 class Identifier;
17 class Type;
18 class Expression;
19
20 namespace dmd
21 {
22 // in enumsem.d
23 Expression *getDefaultValue(EnumDeclaration *ed, Loc loc);
24 }
25
26 class EnumDeclaration final : public ScopeDsymbol
27 {
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;
36 */
37 Type *type; // the TypeEnum
38 Type *memtype; // type of the members
39 Visibility visibility;
40
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);
53
54 EnumDeclaration *syntaxCopy(Dsymbol *s) override;
55 Type *getType() override;
56 const char *kind() const override;
57 bool isDeprecated() const override; // is Dsymbol deprecated?
58 Visibility visible() override;
59 bool isSpecial() const;
60
61
62 Symbol *sinit;
63 void accept(Visitor *v) override { v->visit(this); }
64 };
65
66
67 class EnumMember final : public VarDeclaration
68 {
69 public:
70 /* Can take the following forms:
71 * 1. id
72 * 2. id = value
73 * 3. type id = value
74 */
75 Expression *&value();
76
77 // A cast() is injected to 'value' after semantic(),
78 // but 'origValue' will preserve the original value,
79 // or previous value + 1 if none was specified.
80 Expression *origValue;
81 Type *origType;
82
83 EnumDeclaration *ed;
84
85 EnumMember *syntaxCopy(Dsymbol *s) override;
86 const char *kind() const override;
87
88 void accept(Visitor *v) override { v->visit(this); }
89 };