Mercurial > projects > ddmd
diff dmd/VarDeclaration.d @ 12:832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
Some unittest-specific functions implemented
author | korDen |
---|---|
date | Mon, 12 Apr 2010 15:13:00 +0400 |
parents | 10317f0c89a5 |
children | 460959608115 |
line wrap: on
line diff
--- a/dmd/VarDeclaration.d Wed Mar 31 16:29:36 2010 +0400 +++ b/dmd/VarDeclaration.d Mon Apr 12 15:13:00 2010 +0400 @@ -757,9 +757,38 @@ return true; } - int needsAutoDtor() + /****************************************** + * Return TRUE if variable needs to call the destructor. + */ + bool needsAutoDtor() { - assert(false); + //printf("VarDeclaration.needsAutoDtor() %s\n", toChars()); + + if (noauto || storage_class & STCnodtor) + return false; + + // Destructors for structs and arrays of structs + Type tv = type.toBasetype(); + while (tv.ty == Tsarray) + { + TypeSArray ta = cast(TypeSArray)tv; + tv = tv.nextOf().toBasetype(); + } + if (tv.ty == Tstruct) + { + TypeStruct ts = cast(TypeStruct)tv; + StructDeclaration sd = ts.sym; + if (sd.dtor) + return true; + } + + // Destructors for classes + if (storage_class & (STCauto | STCscope)) + { + if (type.isClassHandle()) + return true; + } + return false; } }