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"
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 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; }
59 void accept(Visitor
*v
) override
{ v
->visit(this); }
63 class EnumMember final
: public VarDeclaration
66 /* Can take the following forms:
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
;
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); }