]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/d/dmd/enum.h
072eacf583e5ab89fb7a605b042d525ebcd85e3b
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2018 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * http://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * http://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/dlang/dmd/blob/master/src/dmd/enum.h
13 #include "root/root.h"
15 #include "declaration.h"
23 class EnumDeclaration
: public ScopeDsymbol
26 /* The separate, and distinct, cases are:
28 * 2. enum : memtype { ... }
30 * 4. enum id : memtype { ... }
31 * 5. enum id : memtype;
34 Type
*type
; // the TypeEnum
35 Type
*memtype
; // type of the members
40 Expression
*defaultval
; // default initializer
46 EnumDeclaration(Loc loc
, Identifier
*id
, Type
*memtype
);
47 Dsymbol
*syntaxCopy(Dsymbol
*s
);
48 void addMember(Scope
*sc
, ScopeDsymbol
*sds
);
49 void setScope(Scope
*sc
);
50 void semantic(Scope
*sc
);
51 bool oneMember(Dsymbol
**ps
, Identifier
*ident
);
54 Dsymbol
*search(const Loc
&loc
, Identifier
*ident
, int flags
= SearchLocalsOnly
);
55 bool isDeprecated(); // is Dsymbol deprecated?
57 Expression
*getMaxMinValue(Loc loc
, Identifier
*id
);
58 bool isSpecial() const;
59 Expression
*getDefaultValue(Loc loc
);
60 Type
*getMemtype(Loc loc
);
62 EnumDeclaration
*isEnumDeclaration() { return this; }
65 void accept(Visitor
*v
) { v
->visit(this); }
69 class EnumMember
: 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(Loc loc
, Identifier
*id
, Expression
*value
, Type
*origType
);
88 Dsymbol
*syntaxCopy(Dsymbol
*s
);
90 void semantic(Scope
*sc
);
91 Expression
*getVarExp(Loc loc
, Scope
*sc
);
93 EnumMember
*isEnumMember() { return this; }
94 void accept(Visitor
*v
) { v
->visit(this); }