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
14 #include "declaration.h"
23 Expression
*getDefaultValue(EnumDeclaration
*ed
, const Loc
&loc
);
26 class EnumDeclaration final
: public ScopeDsymbol
29 /* The separate, and distinct, cases are:
31 * 2. enum : memtype { ... }
33 * 4. enum id : memtype { ... }
34 * 5. enum id : memtype;
37 Type
*type
; // the TypeEnum
38 Type
*memtype
; // type of the members
39 Visibility visibility
;
43 Expression
*defaultval
; // default initializer
47 bool isdeprecated() const;
48 bool isdeprecated(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; }
65 void accept(Visitor
*v
) override
{ v
->visit(this); }
69 class EnumMember final
: public VarDeclaration
72 /* Can take the following forms:
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
;
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); }