Mercurial > projects > ldc
comparison dmd/enum.c @ 336:aaade6ded589 trunk
[svn r357] Merged DMD 1.033
author | lindquist |
---|---|
date | Sat, 12 Jul 2008 19:38:31 +0200 |
parents | c53b6e3fe49a |
children | 1860414bf3b7 |
comparison
equal
deleted
inserted
replaced
335:17b844102023 | 336:aaade6ded589 |
---|---|
1 | 1 |
2 // Copyright (c) 1999-2006 by Digital Mars | 2 // Copyright (c) 1999-2008 by Digital Mars |
3 // All Rights Reserved | 3 // All Rights Reserved |
4 // written by Walter Bright | 4 // written by Walter Bright |
5 // http://www.digitalmars.com | 5 // http://www.digitalmars.com |
6 // License for redistribution is by either the Artistic License | 6 // License for redistribution is by either the Artistic License |
7 // in artistic.txt, or the GNU General Public License in gnu.txt. | 7 // in artistic.txt, or the GNU General Public License in gnu.txt. |
12 | 12 |
13 #include "root.h" | 13 #include "root.h" |
14 #include "enum.h" | 14 #include "enum.h" |
15 #include "mtype.h" | 15 #include "mtype.h" |
16 #include "scope.h" | 16 #include "scope.h" |
17 #include "declaration.h" | |
17 | 18 |
18 /********************************* EnumDeclaration ****************************/ | 19 /********************************* EnumDeclaration ****************************/ |
19 | 20 |
20 EnumDeclaration::EnumDeclaration(Loc loc, Identifier *id, Type *memtype) | 21 EnumDeclaration::EnumDeclaration(Loc loc, Identifier *id, Type *memtype) |
21 : ScopeDsymbol(id) | 22 : ScopeDsymbol(id) |
25 this->memtype = memtype; | 26 this->memtype = memtype; |
26 maxval = 0; | 27 maxval = 0; |
27 minval = 0; | 28 minval = 0; |
28 defaultval = 0; | 29 defaultval = 0; |
29 sinit = NULL; | 30 sinit = NULL; |
31 isdeprecated = 0; | |
30 } | 32 } |
31 | 33 |
32 Dsymbol *EnumDeclaration::syntaxCopy(Dsymbol *s) | 34 Dsymbol *EnumDeclaration::syntaxCopy(Dsymbol *s) |
33 { | 35 { |
34 Type *t = NULL; | 36 Type *t = NULL; |
55 //printf("EnumDeclaration::semantic(sd = %p, '%s')\n", sc->scopesym, sc->scopesym->toChars()); | 57 //printf("EnumDeclaration::semantic(sd = %p, '%s')\n", sc->scopesym, sc->scopesym->toChars()); |
56 if (symtab) // if already done | 58 if (symtab) // if already done |
57 return; | 59 return; |
58 if (!memtype) | 60 if (!memtype) |
59 memtype = Type::tint32; | 61 memtype = Type::tint32; |
62 if (sc->stc & STCdeprecated) | |
63 isdeprecated = 1; | |
64 | |
60 parent = sc->scopesym; | 65 parent = sc->scopesym; |
61 memtype = memtype->semantic(loc, sc); | 66 memtype = memtype->semantic(loc, sc); |
62 | 67 |
63 /* Check to see if memtype is forward referenced | 68 /* Check to see if memtype is forward referenced |
64 */ | 69 */ |
263 Type *EnumDeclaration::getType() | 268 Type *EnumDeclaration::getType() |
264 { | 269 { |
265 return type; | 270 return type; |
266 } | 271 } |
267 | 272 |
268 char *EnumDeclaration::kind() | 273 const char *EnumDeclaration::kind() |
269 { | 274 { |
270 return "enum"; | 275 return "enum"; |
276 } | |
277 | |
278 int EnumDeclaration::isDeprecated() | |
279 { | |
280 return isdeprecated; | |
271 } | 281 } |
272 | 282 |
273 /********************************* EnumMember ****************************/ | 283 /********************************* EnumMember ****************************/ |
274 | 284 |
275 EnumMember::EnumMember(Loc loc, Identifier *id, Expression *value) | 285 EnumMember::EnumMember(Loc loc, Identifier *id, Expression *value) |
304 buf->writestring(" = "); | 314 buf->writestring(" = "); |
305 value->toCBuffer(buf, hgs); | 315 value->toCBuffer(buf, hgs); |
306 } | 316 } |
307 } | 317 } |
308 | 318 |
309 char *EnumMember::kind() | 319 const char *EnumMember::kind() |
310 { | 320 { |
311 return "enum member"; | 321 return "enum member"; |
312 } | 322 } |
313 | 323 |
314 | 324 |