Mercurial > projects > ldc
view dmd2/enum.h @ 1317:4099548c80e0
Allocate objects on the stack if they (a) don't have a destructor, and
(b) don't override the delete operator (on top of the regular conditions for
stack allocation that also apply to arrays, structs, etc.).
The "no destructor" clause is not strictly necessary, but calling them at the
right time would be tricky to say the least; it would involve, among other
things, "manually" inserting a try-finally block around anything that might
throw exceptions not caught in the current function.
Note: objects with custom new operators are automatically ignored because they
don't use the regular allocation runtime call, so there's no need to pay special
attention to them.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sat, 09 May 2009 00:50:15 +0200 |
parents | f04dde6e882c |
children | 638d16625da2 |
line wrap: on
line source
// Compiler implementation of the D programming language // Copyright (c) 1999-2008 by Digital Mars // All Rights Reserved // written by Walter Bright // http://www.digitalmars.com // License for redistribution is by either the Artistic License // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. #ifndef DMD_ENUM_H #define DMD_ENUM_H #ifdef __DMC__ #pragma once #endif /* __DMC__ */ #include "root.h" #include "dsymbol.h" struct Identifier; struct Type; struct Expression; #ifdef _DH struct HdrGenState; #endif struct EnumDeclaration : ScopeDsymbol { /* enum ident : memtype { ... } */ Type *type; // the TypeEnum Type *memtype; // type of the members #if DMDV1 integer_t maxval; integer_t minval; integer_t defaultval; // default initializer #else Expression *maxval; Expression *minval; Expression *defaultval; // default initializer Scope *scope; // !=NULL means context to use #endif int isdeprecated; EnumDeclaration(Loc loc, Identifier *id, Type *memtype); Dsymbol *syntaxCopy(Dsymbol *s); void semantic(Scope *sc); int oneMember(Dsymbol **ps); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); Type *getType(); const char *kind(); #if DMDV2 Dsymbol *search(Loc, Identifier *ident, int flags); #endif int isDeprecated(); // is Dsymbol deprecated? void emitComment(Scope *sc); void toDocBuffer(OutBuffer *buf); EnumDeclaration *isEnumDeclaration() { return this; } void toObjFile(int multiobj); // compile to .obj file void toDebug(); int cvMember(unsigned char *p); Symbol *sinit; Symbol *toInitializer(); }; struct EnumMember : Dsymbol { Expression *value; Type *type; EnumMember(Loc loc, Identifier *id, Expression *value, Type *type); Dsymbol *syntaxCopy(Dsymbol *s); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); const char *kind(); void emitComment(Scope *sc); void toDocBuffer(OutBuffer *buf); EnumMember *isEnumMember() { return this; } }; #endif /* DMD_ENUM_H */