1
1
2
2
// Compiler implementation of the D programming language
3
- // Copyright (c) 1999-2012 by Digital Mars
3
+ // Copyright (c) 1999-2013 by Digital Mars
4
4
// All Rights Reserved
5
5
// written by Walter Bright
6
6
// http://www.digitalmars.com
18
18
#include " root.h"
19
19
20
20
#include " dsymbol.h"
21
+ #include " declaration.h"
21
22
22
23
#if IN_LLVM
23
24
#include < vector>
@@ -74,29 +75,32 @@ struct AggregateDeclaration : ScopeDsymbol
74
75
bool isdeprecated; // !=0 if deprecated
75
76
76
77
#if DMDV2
77
- bool isnested; // !=0 if is nested
78
+ Dsymbol *enclosing; /* !=NULL if is nested
79
+ * pointing to the dsymbol that directly enclosing it.
80
+ * 1. The function that enclosing it (nested struct and class)
81
+ * 2. The class that enclosing it (nested class only)
82
+ * 3. If enclosing aggregate is template, its enclosing dsymbol.
83
+ * See AggregateDeclaraton::makeNested for the details.
84
+ */
78
85
VarDeclaration *vthis; // 'this' parameter if this aggregate is nested
79
86
#endif
80
87
// Special member functions
81
- InvariantDeclaration *inv; // invariant
88
+ FuncDeclarations invs; // Array of invariants
89
+ FuncDeclaration *inv; // invariant
82
90
NewDeclaration *aggNew; // allocator
83
91
DeleteDeclaration *aggDelete; // deallocator
84
92
85
93
#if DMDV2
86
- // CtorDeclaration *ctor;
87
94
Dsymbol *ctor; // CtorDeclaration or TemplateDeclaration
88
- CtorDeclaration *defaultCtor; // default constructor
95
+ CtorDeclaration *defaultCtor; // default constructor - should have no arguments, because
96
+ // it would be stored in TypeInfo_Class.defaultConstructor
89
97
Dsymbol *aliasthis; // forward unresolved lookups to aliasthis
90
98
bool noDefaultCtor; // no default construction
91
99
#endif
92
100
93
101
FuncDeclarations dtors; // Array of destructors
94
102
FuncDeclaration *dtor; // aggregate destructor
95
103
96
- #ifdef IN_GCC
97
- Expressions *attributes; // GCC decl/type attributes
98
- #endif
99
-
100
104
Expression *getRTInfo; // pointer to GC info generated by object.RTInfo(this)
101
105
102
106
AggregateDeclaration (Loc loc, Identifier *id);
@@ -112,18 +116,21 @@ struct AggregateDeclaration : ScopeDsymbol
112
116
Type *getType ();
113
117
int firstFieldInUnion (int indx); // first field in union that includes indx
114
118
int numFieldsInUnion (int firstIndex); // #fields in union starting at index
115
- int isDeprecated (); // is aggregate deprecated?
119
+ bool isDeprecated (); // is aggregate deprecated?
116
120
FuncDeclaration *buildDtor (Scope *sc);
117
- int isNested ();
121
+ FuncDeclaration *buildInv (Scope *sc);
122
+ bool isNested ();
123
+ void makeNested ();
118
124
int isExport ();
119
125
120
126
void emitComment (Scope *sc);
121
127
void toJson (JsonOut *json);
122
128
void toDocBuffer (OutBuffer *buf, Scope *sc);
123
129
124
- FuncDeclaration *hasIdentityOpAssign (Scope *sc, Dsymbol *assign);
130
+ FuncDeclaration *hasIdentityOpAssign (Scope *sc);
131
+ FuncDeclaration *hasIdentityOpEquals (Scope *sc);
125
132
126
- char *mangle (bool isv = false );
133
+ const char *mangle (bool isv = false );
127
134
128
135
// For access checking
129
136
virtual PROT getAccess (Dsymbol *smember); // determine access to smember
@@ -173,7 +180,7 @@ struct StructDeclaration : AggregateDeclaration
173
180
void semantic (Scope *sc);
174
181
Dsymbol *search (Loc, Identifier *ident, int flags);
175
182
void toCBuffer (OutBuffer *buf, HdrGenState *hgs);
176
- char *mangle (bool isv = false );
183
+ const char *mangle (bool isv = false );
177
184
const char *kind ();
178
185
void finalizeSize (Scope *sc);
179
186
bool isPOD ();
@@ -184,12 +191,10 @@ struct StructDeclaration : AggregateDeclaration
184
191
int needOpAssign ();
185
192
int needOpEquals ();
186
193
FuncDeclaration *buildOpAssign (Scope *sc);
187
- FuncDeclaration *buildOpEquals (Scope *sc);
188
194
FuncDeclaration *buildPostBlit (Scope *sc);
189
195
FuncDeclaration *buildCpCtor (Scope *sc);
190
-
196
+ FuncDeclaration * buildOpEquals (Scope *sc);
191
197
FuncDeclaration *buildXopEquals (Scope *sc);
192
- void makeNested ();
193
198
#endif
194
199
void toDocBuffer (OutBuffer *buf, Scope *sc);
195
200
@@ -273,16 +278,16 @@ struct ClassDeclaration : AggregateDeclaration
273
278
274
279
BaseClasses *vtblInterfaces; // array of base interfaces that have
275
280
// their own vtbl[]
281
+
276
282
TypeInfoClassDeclaration *vclassinfo; // the ClassInfo object for this ClassDeclaration
277
283
int com; // !=0 if this is a COM class (meaning
278
284
// it derives from IUnknown)
279
- int isscope; // !=0 if this is an auto class
285
+ int isscope; // !=0 if this is an auto class
280
286
int isabstract; // !=0 if abstract class
281
- #if DMDV1
282
- bool isnested; // !=0 if is nested
283
- VarDeclaration *vthis; // 'this' parameter if this class is nested
284
- #endif
285
287
int inuse; // to prevent recursive attempts
288
+ enum Semantic doAncestorsSemantic; // Before searching symbol, whole ancestors should finish
289
+ // calling semantic() at least once, due to fill symtab
290
+ // and do addMember(). [== Semantic(Start,In,Done)]
286
291
287
292
ClassDeclaration (Loc loc, Identifier *id, BaseClasses *baseclasses);
288
293
Dsymbol *syntaxCopy (Dsymbol *s);
@@ -295,15 +300,12 @@ struct ClassDeclaration : AggregateDeclaration
295
300
296
301
virtual int isBaseInfoComplete ();
297
302
Dsymbol *search (Loc, Identifier *ident, int flags);
298
- Dsymbol *searchBase (Loc, Identifier *ident);
303
+ ClassDeclaration *searchBase (Loc, Identifier *ident);
299
304
#if DMDV2
300
305
int isFuncHidden (FuncDeclaration *fd);
301
306
#endif
302
307
FuncDeclaration *findFunc (Identifier *ident, TypeFunction *tf);
303
308
void interfaceSemantic (Scope *sc);
304
- #if DMDV1
305
- int isNested ();
306
- #endif
307
309
int isCOMclass ();
308
310
virtual int isCOMinterface ();
309
311
#if DMDV2
@@ -312,7 +314,7 @@ struct ClassDeclaration : AggregateDeclaration
312
314
int isAbstract ();
313
315
virtual int vtblOffset ();
314
316
const char *kind ();
315
- char *mangle (bool isv = false );
317
+ const char *mangle (bool isv = false );
316
318
void toDocBuffer (OutBuffer *buf, Scope *sc);
317
319
318
320
PROT getAccess (Dsymbol *smember); // determine access to smember
0 commit comments