Mercurial > projects > ldc
annotate dmd/aggregate.h @ 1624:ae8a94d87ca9
Merge DMD r318: bugzilla 2029 Typesafe variadic functions don't...
bugzilla 2029 Typesafe variadic functions don't work in CTFE.
---
dmd/aggregate.h | 1 +
dmd/struct.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:22 -0300 |
parents | a413ae7329bf |
children | 44b145be2ef5 |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2008 by Digital Mars | |
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_AGGREGATE_H | |
12 #define DMD_AGGREGATE_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include "root.h" | |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
19 |
159 | 20 #include "dsymbol.h" |
21 | |
22 #include <vector> | |
23 #include <set> | |
24 #include <map> | |
25 | |
26 struct Identifier; | |
27 struct Type; | |
28 struct TypeFunction; | |
29 struct Expression; | |
30 struct FuncDeclaration; | |
31 struct CtorDeclaration; | |
32 struct DtorDeclaration; | |
33 struct InvariantDeclaration; | |
34 struct NewDeclaration; | |
35 struct DeleteDeclaration; | |
36 struct InterfaceDeclaration; | |
37 struct ClassInfoDeclaration; | |
38 struct VarDeclaration; | |
39 struct dt_t; | |
40 | |
41 namespace llvm | |
42 { | |
43 class Type; | |
44 class Value; | |
45 class Constant; | |
46 class ConstantStruct; | |
47 class GlobalVariable; | |
48 } | |
49 | |
50 struct AggregateDeclaration : ScopeDsymbol | |
51 { | |
52 Type *type; | |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
53 StorageClass storage_class; |
159 | 54 enum PROT protection; |
55 Type *handle; // 'this' type | |
56 unsigned structsize; // size of struct | |
57 unsigned alignsize; // size of struct for alignment purposes | |
58 unsigned structalign; // struct member alignment in effect | |
59 int hasUnions; // set if aggregate has overlapping fields | |
60 Array fields; // VarDeclaration fields | |
61 unsigned sizeok; // set when structsize contains valid data | |
62 // 0: no size | |
63 // 1: size is correct | |
64 // 2: cannot determine size; fwd referenced | |
65 int isdeprecated; // !=0 if deprecated | |
66 | |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
67 #if DMDV2 |
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
68 int isnested; // !=0 if is nested |
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
69 VarDeclaration *vthis; // 'this' parameter if this aggregate is nested |
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
70 #endif |
159 | 71 // Special member functions |
72 InvariantDeclaration *inv; // invariant | |
73 NewDeclaration *aggNew; // allocator | |
74 DeleteDeclaration *aggDelete; // deallocator | |
75 | |
1587 | 76 #if DMDV2 |
77 //CtorDeclaration *ctor; | |
78 Dsymbol *ctor; // CtorDeclaration or TemplateDeclaration | |
79 CtorDeclaration *defaultCtor; // default constructor | |
80 Dsymbol *aliasthis; // forward unresolved lookups to aliasthis | |
81 #endif | |
82 | |
336 | 83 FuncDeclarations dtors; // Array of destructors |
84 FuncDeclaration *dtor; // aggregate destructor | |
85 | |
159 | 86 #ifdef IN_GCC |
87 Array methods; // flat list of all methods for debug information | |
88 #endif | |
89 | |
90 AggregateDeclaration(Loc loc, Identifier *id); | |
91 void semantic2(Scope *sc); | |
92 void semantic3(Scope *sc); | |
93 void inlineScan(); | |
94 unsigned size(Loc loc); | |
95 static void alignmember(unsigned salign, unsigned size, unsigned *poffset); | |
96 Type *getType(); | |
97 void addField(Scope *sc, VarDeclaration *v); | |
98 int isDeprecated(); // is aggregate deprecated? | |
99 FuncDeclaration *buildDtor(Scope *sc); | |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
100 int isNested(); |
159 | 101 |
102 void emitComment(Scope *sc); | |
1587 | 103 void toJsonBuffer(OutBuffer *buf); |
159 | 104 void toDocBuffer(OutBuffer *buf); |
105 | |
106 // For access checking | |
107 virtual PROT getAccess(Dsymbol *smember); // determine access to smember | |
108 int isFriendOf(AggregateDeclaration *cd); | |
109 int hasPrivateAccess(Dsymbol *smember); // does smember have private access to members of this class? | |
110 void accessCheck(Loc loc, Scope *sc, Dsymbol *smember); | |
111 | |
112 enum PROT prot(); | |
113 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
806
diff
changeset
|
114 #if IN_DMD |
159 | 115 // Back end |
116 Symbol *stag; // tag symbol for debug data | |
117 Symbol *sinit; | |
118 Symbol *toInitializer(); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
806
diff
changeset
|
119 #endif |
159 | 120 |
121 AggregateDeclaration *isAggregateDeclaration() { return this; } | |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1367
diff
changeset
|
122 |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1367
diff
changeset
|
123 #if IN_LLVM |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1367
diff
changeset
|
124 // Aggregates that wouldn't have gotten semantic3'ed if we weren't inlining set this flag. |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1367
diff
changeset
|
125 bool availableExternally; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1367
diff
changeset
|
126 #endif |
159 | 127 }; |
128 | |
129 struct AnonymousAggregateDeclaration : AggregateDeclaration | |
130 { | |
131 AnonymousAggregateDeclaration() | |
132 : AggregateDeclaration(0, NULL) | |
133 { | |
134 } | |
135 | |
136 AnonymousAggregateDeclaration *isAnonymousAggregateDeclaration() { return this; } | |
137 }; | |
138 | |
139 struct StructDeclaration : AggregateDeclaration | |
140 { | |
141 int zeroInit; // !=0 if initialize with 0 fill | |
336 | 142 #if DMDV2 |
143 int hasIdentityAssign; // !=0 if has identity opAssign | |
144 FuncDeclaration *cpctor; // generated copy-constructor, if any | |
145 | |
146 FuncDeclarations postblits; // Array of postblit functions | |
147 FuncDeclaration *postblit; // aggregate postblit | |
148 #endif | |
159 | 149 |
150 StructDeclaration(Loc loc, Identifier *id); | |
151 Dsymbol *syntaxCopy(Dsymbol *s); | |
152 void semantic(Scope *sc); | |
1624
ae8a94d87ca9
Merge DMD r318: bugzilla 2029 Typesafe variadic functions don't...
Leandro Lucarella <llucax@gmail.com>
parents:
1602
diff
changeset
|
153 Dsymbol *search(Loc, Identifier *ident, int flags); |
159 | 154 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
155 char *mangle(); | |
336 | 156 const char *kind(); |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
157 #if DMDV1 |
159 | 158 Expression *cloneMembers(); |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
159 #endif |
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
160 #if DMDV2 |
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
161 int needOpAssign(); |
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
162 FuncDeclaration *buildOpAssign(Scope *sc); |
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
163 FuncDeclaration *buildPostBlit(Scope *sc); |
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
164 FuncDeclaration *buildCpCtor(Scope *sc); |
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
165 #endif |
159 | 166 void toDocBuffer(OutBuffer *buf); |
167 | |
168 PROT getAccess(Dsymbol *smember); // determine access to smember | |
169 | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
170 #if IN_DMD |
336 | 171 void toObjFile(int multiobj); // compile to .obj file |
159 | 172 void toDt(dt_t **pdt); |
173 void toDebug(); // to symbolic debug info | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
174 #endif |
159 | 175 |
176 StructDeclaration *isStructDeclaration() { return this; } | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
177 |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
178 #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
|
179 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
|
180 #endif |
159 | 181 }; |
182 | |
183 struct UnionDeclaration : StructDeclaration | |
184 { | |
185 UnionDeclaration(Loc loc, Identifier *id); | |
186 Dsymbol *syntaxCopy(Dsymbol *s); | |
336 | 187 const char *kind(); |
159 | 188 |
189 UnionDeclaration *isUnionDeclaration() { return this; } | |
190 }; | |
191 | |
806
96b404ba7eb0
Move storage of final vtbl from BaseClass to IrInterface: BaseClass instances are shared!
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
192 // warning: two classes with the same base class share the same |
96b404ba7eb0
Move storage of final vtbl from BaseClass to IrInterface: BaseClass instances are shared!
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
193 // BaseClass instance. |
159 | 194 struct BaseClass |
195 { | |
196 Type *type; // (before semantic processing) | |
197 enum PROT protection; // protection for the base interface | |
198 | |
199 ClassDeclaration *base; | |
200 int offset; // 'this' pointer offset | |
201 Array vtbl; // for interfaces: Array of FuncDeclaration's | |
202 // making up the vtbl[] | |
203 | |
204 int baseInterfaces_dim; | |
205 BaseClass *baseInterfaces; // if BaseClass is an interface, these | |
206 // are a copy of the InterfaceDeclaration::interfaces | |
207 | |
208 BaseClass(); | |
209 BaseClass(Type *type, enum PROT protection); | |
210 | |
211 int fillVtbl(ClassDeclaration *cd, Array *vtbl, int newinstance); | |
212 void copyBaseInterfaces(BaseClasses *); | |
213 }; | |
214 | |
336 | 215 #if DMDV2 |
1367
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1147
diff
changeset
|
216 #define CLASSINFO_SIZE (0x3C+16+4) // value of ClassInfo.size |
159 | 217 #else |
1367
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1147
diff
changeset
|
218 #define CLASSINFO_SIZE (0x3C+12+4) // value of ClassInfo.size |
159 | 219 #endif |
220 | |
221 struct ClassDeclaration : AggregateDeclaration | |
222 { | |
223 static ClassDeclaration *object; | |
224 static ClassDeclaration *classinfo; | |
225 | |
226 ClassDeclaration *baseClass; // NULL only if this is Object | |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
227 #if DMDV1 |
159 | 228 CtorDeclaration *ctor; |
229 CtorDeclaration *defaultCtor; // default constructor | |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
230 #endif |
159 | 231 FuncDeclaration *staticCtor; |
232 FuncDeclaration *staticDtor; | |
233 Array vtbl; // Array of FuncDeclaration's making up the vtbl[] | |
234 Array vtblFinal; // More FuncDeclaration's that aren't in vtbl[] | |
235 | |
236 BaseClasses baseclasses; // Array of BaseClass's; first is super, | |
237 // rest are Interface's | |
238 | |
239 int interfaces_dim; | |
240 BaseClass **interfaces; // interfaces[interfaces_dim] for this class | |
241 // (does not include baseClass) | |
242 | |
243 BaseClasses *vtblInterfaces; // array of base interfaces that have | |
244 // their own vtbl[] | |
245 | |
246 ClassInfoDeclaration *vclassinfo; // the ClassInfo object for this ClassDeclaration | |
247 int com; // !=0 if this is a COM class (meaning | |
248 // it derives from IUnknown) | |
1530
05c235309d6f
Make the auto storage class never have the same meaning as scope.
Christian Kamm <kamm incasoftware de>
parents:
1482
diff
changeset
|
249 int isscope; // !=0 if this is a scope class |
159 | 250 int isabstract; // !=0 if abstract class |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
251 #if DMDV1 |
159 | 252 int isnested; // !=0 if is nested |
253 VarDeclaration *vthis; // 'this' parameter if this class is nested | |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
254 #endif |
159 | 255 int inuse; // to prevent recursive attempts |
256 | |
257 ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses); | |
258 Dsymbol *syntaxCopy(Dsymbol *s); | |
259 void semantic(Scope *sc); | |
260 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
261 int isBaseOf2(ClassDeclaration *cd); | |
262 | |
263 #define OFFSET_RUNTIME 0x76543210 | |
264 virtual int isBaseOf(ClassDeclaration *cd, int *poffset); | |
265 | |
266 Dsymbol *search(Loc, Identifier *ident, int flags); | |
336 | 267 #if DMDV2 |
159 | 268 int isFuncHidden(FuncDeclaration *fd); |
269 #endif | |
270 FuncDeclaration *findFunc(Identifier *ident, TypeFunction *tf); | |
271 void interfaceSemantic(Scope *sc); | |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
272 #if DMDV1 |
159 | 273 int isNested(); |
1602
a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
274 #endif |
159 | 275 int isCOMclass(); |
276 virtual int isCOMinterface(); | |
336 | 277 #if DMDV2 |
159 | 278 virtual int isCPPinterface(); |
279 #endif | |
280 int isAbstract(); | |
281 virtual int vtblOffset(); | |
336 | 282 const char *kind(); |
159 | 283 char *mangle(); |
284 void toDocBuffer(OutBuffer *buf); | |
285 | |
286 PROT getAccess(Dsymbol *smember); // determine access to smember | |
287 | |
288 void addLocalClass(ClassDeclarations *); | |
289 | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
290 #if IN_DMD |
159 | 291 // Back end |
336 | 292 void toObjFile(int multiobj); // compile to .obj file |
159 | 293 void toDebug(); |
294 unsigned baseVtblOffset(BaseClass *bc); | |
295 Symbol *toSymbol(); | |
296 Symbol *toVtblSymbol(); | |
297 void toDt(dt_t **pdt); | |
298 void toDt2(dt_t **pdt, ClassDeclaration *cd); | |
299 | |
300 Symbol *vtblsym; | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
806
diff
changeset
|
301 #endif |
159 | 302 |
303 ClassDeclaration *isClassDeclaration() { return (ClassDeclaration *)this; } | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
304 |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
305 #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
|
306 virtual 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
|
307 #endif |
159 | 308 }; |
309 | |
310 struct InterfaceDeclaration : ClassDeclaration | |
311 { | |
336 | 312 #if DMDV2 |
159 | 313 int cpp; // !=0 if this is a C++ interface |
314 #endif | |
315 InterfaceDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses); | |
316 Dsymbol *syntaxCopy(Dsymbol *s); | |
317 void semantic(Scope *sc); | |
318 int isBaseOf(ClassDeclaration *cd, int *poffset); | |
319 int isBaseOf(BaseClass *bc, int *poffset); | |
336 | 320 const char *kind(); |
159 | 321 int vtblOffset(); |
336 | 322 #if DMDV2 |
159 | 323 int isCPPinterface(); |
324 #endif | |
325 virtual int isCOMinterface(); | |
326 | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
327 #if IN_DMD |
336 | 328 void toObjFile(int multiobj); // compile to .obj file |
159 | 329 Symbol *toSymbol(); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
806
diff
changeset
|
330 #endif |
159 | 331 |
332 InterfaceDeclaration *isInterfaceDeclaration() { return this; } | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
333 |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
334 #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
|
335 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
|
336 #endif |
159 | 337 }; |
338 | |
339 #endif /* DMD_AGGREGATE_H */ |