2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2023 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"
20 class EnumDeclaration final
: public ScopeDsymbol
23 /* The separate, and distinct, cases are:
25 * 2. enum : memtype { ... }
27 * 4. enum id : memtype { ... }
28 * 5. enum id : memtype;
31 Type
*type
; // the TypeEnum
32 Type
*memtype
; // type of the members
33 Visibility visibility
;
37 Expression
*defaultval
; // default initializer
41 bool isdeprecated() const;
42 bool isdeprecated(bool v
);
48 EnumDeclaration
*syntaxCopy(Dsymbol
*s
) override
;
49 void setScope(Scope
*sc
) override
;
50 bool oneMember(Dsymbol
**ps
, Identifier
*ident
) override
;
51 Type
*getType() override
;
52 const char *kind() const override
;
53 bool isDeprecated() const override
; // is Dsymbol deprecated?
54 Visibility
visible() override
;
55 bool isSpecial() const;
56 Expression
*getDefaultValue(const Loc
&loc
);
57 Type
*getMemtype(const Loc
&loc
);
59 EnumDeclaration
*isEnumDeclaration() override
{ return this; }
62 void accept(Visitor
*v
) override
{ v
->visit(this); }
66 class EnumMember final
: public VarDeclaration
69 /* Can take the following forms:
76 // A cast() is injected to 'value' after semantic(),
77 // but 'origValue' will preserve the original value,
78 // or previous value + 1 if none was specified.
79 Expression
*origValue
;
84 EnumMember
*syntaxCopy(Dsymbol
*s
) override
;
85 const char *kind() const override
;
87 EnumMember
*isEnumMember() override
{ return this; }
88 void accept(Visitor
*v
) override
{ v
->visit(this); }