Mercurial > projects > ldc
annotate dmd/enum.h @ 1168:ab186e535e72
A different fix to #218 and DMD2682 that does not lead to constant folding regressions.
Fixes run/const_15, run/c/const_16_B.
The price is removing the lvalueness of struct literals. If it turns out too
much code depends on this behavior or we don't want to break with DMD, we
could keep struct literals as lvalues and instead convert struct literals used
as expression initializers into struct initializers.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 29 Mar 2009 11:43:45 +0200 |
parents | dbe4af57b240 |
children | e961851fb8be |
rev | line source |
---|---|
1 | 1 |
2 // Compiler implementation of the D programming language | |
336 | 3 // Copyright (c) 1999-2008 by Digital Mars |
1 | 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 { | |
31 Type *type; // the TypeEnum | |
32 Type *memtype; // type of the members | |
336 | 33 |
34 #if DMDV1 | |
1 | 35 integer_t maxval; |
36 integer_t minval; | |
37 integer_t defaultval; // default initializer | |
336 | 38 #else |
39 Expression *maxval; | |
40 Expression *minval; | |
41 Expression *defaultval; // default initializer | |
42 | |
43 Scope *scope; // !=NULL means context to use | |
44 #endif | |
45 int isdeprecated; | |
1 | 46 |
47 EnumDeclaration(Loc loc, Identifier *id, Type *memtype); | |
48 Dsymbol *syntaxCopy(Dsymbol *s); | |
49 void semantic(Scope *sc); | |
50 int oneMember(Dsymbol **ps); | |
51 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
52 Type *getType(); | |
336 | 53 const char *kind(); |
54 #if DMDV2 | |
55 Dsymbol *search(Loc, Identifier *ident, int flags); | |
56 #endif | |
57 int isDeprecated(); // is Dsymbol deprecated? | |
1 | 58 |
59 void emitComment(Scope *sc); | |
60 void toDocBuffer(OutBuffer *buf); | |
61 | |
62 EnumDeclaration *isEnumDeclaration() { return this; } | |
63 | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
64 #if IN_DMD |
336 | 65 void toObjFile(int multiobj); // compile to .obj file |
1 | 66 void toDebug(); |
67 int cvMember(unsigned char *p); | |
68 | |
69 Symbol *sinit; | |
70 Symbol *toInitializer(); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
336
diff
changeset
|
71 #endif |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
72 |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
73 #if IN_LLVM |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
74 void codegen(Ir*); |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
75 #endif |
1 | 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); | |
336 | 86 const char *kind(); |
1 | 87 |
88 void emitComment(Scope *sc); | |
89 void toDocBuffer(OutBuffer *buf); | |
90 | |
91 EnumMember *isEnumMember() { return this; } | |
92 }; | |
93 | |
94 #endif /* DMD_ENUM_H */ |