1587
|
1
|
|
2 // Compiler implementation of the D programming language
|
|
3 // Copyright (c) 1999-2008 by Digital Mars
|
|
4 // All Rights Reserved
|
|
5 // written by Walter Bright
|
|
6 // http://www.digitalmars.com
|
|
7 // License for redistribution is by either the Artistic License
|
|
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
|
|
9 // See the included readme.txt for details.
|
|
10
|
|
11 #ifndef DMD_ENUM_H
|
|
12 #define DMD_ENUM_H
|
|
13
|
|
14 #ifdef __DMC__
|
|
15 #pragma once
|
|
16 #endif /* __DMC__ */
|
|
17
|
|
18 #include "root.h"
|
|
19 #include "dsymbol.h"
|
|
20
|
|
21 struct Identifier;
|
|
22 struct Type;
|
|
23 struct Expression;
|
|
24 #ifdef _DH
|
|
25 struct HdrGenState;
|
|
26 #endif
|
|
27
|
|
28
|
|
29 struct EnumDeclaration : ScopeDsymbol
|
|
30 { /* enum ident : memtype { ... }
|
|
31 */
|
|
32 Type *type; // the TypeEnum
|
|
33 Type *memtype; // type of the members
|
|
34
|
|
35 #if DMDV1
|
|
36 dinteger_t maxval;
|
|
37 dinteger_t minval;
|
|
38 dinteger_t defaultval; // default initializer
|
|
39 #else
|
|
40 Expression *maxval;
|
|
41 Expression *minval;
|
|
42 Expression *defaultval; // default initializer
|
|
43 #endif
|
|
44 int isdeprecated;
|
|
45
|
|
46 EnumDeclaration(Loc loc, Identifier *id, Type *memtype);
|
|
47 Dsymbol *syntaxCopy(Dsymbol *s);
|
|
48 void semantic(Scope *sc);
|
|
49 int oneMember(Dsymbol **ps);
|
|
50 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
51 Type *getType();
|
|
52 const char *kind();
|
|
53 #if DMDV2
|
|
54 Dsymbol *search(Loc, Identifier *ident, int flags);
|
|
55 #endif
|
|
56 int isDeprecated(); // is Dsymbol deprecated?
|
|
57
|
|
58 void emitComment(Scope *sc);
|
|
59 void toJsonBuffer(OutBuffer *buf);
|
|
60 void toDocBuffer(OutBuffer *buf);
|
|
61
|
|
62 EnumDeclaration *isEnumDeclaration() { return this; }
|
|
63
|
|
64 #if IN_DMD
|
|
65 void toObjFile(int multiobj); // compile to .obj file
|
|
66 void toDebug();
|
|
67 int cvMember(unsigned char *p);
|
|
68
|
|
69 Symbol *sinit;
|
|
70 Symbol *toInitializer();
|
|
71 #endif
|
|
72
|
|
73 #if IN_LLVM
|
|
74 void codegen(Ir*);
|
|
75 #endif
|
|
76 };
|
|
77
|
|
78
|
|
79 struct EnumMember : Dsymbol
|
|
80 {
|
|
81 Expression *value;
|
|
82
|
|
83 EnumMember(Loc loc, Identifier *id, Expression *value);
|
|
84 Dsymbol *syntaxCopy(Dsymbol *s);
|
|
85 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
86 const char *kind();
|
|
87
|
|
88 void emitComment(Scope *sc);
|
|
89 void toJsonBuffer(OutBuffer *buf);
|
|
90 void toDocBuffer(OutBuffer *buf);
|
|
91
|
|
92 EnumMember *isEnumMember() { return this; }
|
|
93 };
|
|
94
|
|
95 #endif /* DMD_ENUM_H */
|