comparison dmd2/aggregate.h @ 1452:638d16625da2

LDC 2 compiles again.
author Robert Clipsham <robert@octarineparrot.com>
date Sat, 30 May 2009 17:23:32 +0100
parents 340acf1535d0
children f62347c22d81
comparison
equal deleted inserted replaced
1423:42bd767ec5a4 1452:638d16625da2
16 #endif /* __DMC__ */ 16 #endif /* __DMC__ */
17 17
18 #include "root.h" 18 #include "root.h"
19 #include "dsymbol.h" 19 #include "dsymbol.h"
20 20
21 #if IN_LLVM
21 #include <vector> 22 #include <vector>
22 #include <set> 23 #include <set>
23 #include <map> 24 #include <map>
25 #endif
24 26
25 struct Identifier; 27 struct Identifier;
26 struct Type; 28 struct Type;
27 struct TypeFunction; 29 struct TypeFunction;
28 struct Expression; 30 struct Expression;
35 struct InterfaceDeclaration; 37 struct InterfaceDeclaration;
36 struct ClassInfoDeclaration; 38 struct ClassInfoDeclaration;
37 struct VarDeclaration; 39 struct VarDeclaration;
38 struct dt_t; 40 struct dt_t;
39 41
42 #if IN_LLVM
40 namespace llvm 43 namespace llvm
41 { 44 {
42 class Type; 45 class Type;
43 class Value; 46 class Value;
44 class Constant; 47 class Constant;
45 class ConstantStruct; 48 class ConstantStruct;
46 class GlobalVariable; 49 class GlobalVariable;
47 } 50 }
51 #endif
48 52
49 struct AggregateDeclaration : ScopeDsymbol 53 struct AggregateDeclaration : ScopeDsymbol
50 { 54 {
51 Type *type; 55 Type *type;
52 unsigned storage_class; 56 unsigned storage_class;
62 // 1: size is correct 66 // 1: size is correct
63 // 2: cannot determine size; fwd referenced 67 // 2: cannot determine size; fwd referenced
64 int isdeprecated; // !=0 if deprecated 68 int isdeprecated; // !=0 if deprecated
65 Scope *scope; // !=NULL means context to use 69 Scope *scope; // !=NULL means context to use
66 70
71 int isnested; // !=0 if is nested
72 VarDeclaration *vthis; // 'this' parameter if this aggregate is nested
73
67 // Special member functions 74 // Special member functions
68 InvariantDeclaration *inv; // invariant 75 InvariantDeclaration *inv; // invariant
69 NewDeclaration *aggNew; // allocator 76 NewDeclaration *aggNew; // allocator
70 DeleteDeclaration *aggDelete; // deallocator 77 DeleteDeclaration *aggDelete; // deallocator
71 78
72 #if DMDV2 79 #if DMDV2
73 CtorDeclaration *ctor; 80 //CtorDeclaration *ctor;
81 Dsymbol *ctor; // CtorDeclaration or TemplateDeclaration
74 CtorDeclaration *defaultCtor; // default constructor 82 CtorDeclaration *defaultCtor; // default constructor
83 Dsymbol *aliasthis; // forward unresolved lookups to aliasthis
75 #endif 84 #endif
76 85
77 FuncDeclarations dtors; // Array of destructors 86 FuncDeclarations dtors; // Array of destructors
78 FuncDeclaration *dtor; // aggregate destructor 87 FuncDeclaration *dtor; // aggregate destructor
79 88
89 static void alignmember(unsigned salign, unsigned size, unsigned *poffset); 98 static void alignmember(unsigned salign, unsigned size, unsigned *poffset);
90 Type *getType(); 99 Type *getType();
91 void addField(Scope *sc, VarDeclaration *v); 100 void addField(Scope *sc, VarDeclaration *v);
92 int isDeprecated(); // is aggregate deprecated? 101 int isDeprecated(); // is aggregate deprecated?
93 FuncDeclaration *buildDtor(Scope *sc); 102 FuncDeclaration *buildDtor(Scope *sc);
103 int isNested();
94 104
95 void emitComment(Scope *sc); 105 void emitComment(Scope *sc);
96 void toDocBuffer(OutBuffer *buf); 106 void toDocBuffer(OutBuffer *buf);
97 107
98 // For access checking 108 // For access checking
101 int hasPrivateAccess(Dsymbol *smember); // does smember have private access to members of this class? 111 int hasPrivateAccess(Dsymbol *smember); // does smember have private access to members of this class?
102 void accessCheck(Loc loc, Scope *sc, Dsymbol *smember); 112 void accessCheck(Loc loc, Scope *sc, Dsymbol *smember);
103 113
104 enum PROT prot(); 114 enum PROT prot();
105 115
116 #if IN_DMD
106 // Back end 117 // Back end
107 Symbol *stag; // tag symbol for debug data 118 Symbol *stag; // tag symbol for debug data
108 Symbol *sinit; 119 Symbol *sinit;
109 Symbol *toInitializer(); 120 Symbol *toInitializer();
121 #endif
110 122
111 AggregateDeclaration *isAggregateDeclaration() { return this; } 123 AggregateDeclaration *isAggregateDeclaration() { return this; }
112 }; 124 };
113 125
114 struct AnonymousAggregateDeclaration : AggregateDeclaration 126 struct AnonymousAggregateDeclaration : AggregateDeclaration
144 FuncDeclaration *buildCpCtor(Scope *sc); 156 FuncDeclaration *buildCpCtor(Scope *sc);
145 void toDocBuffer(OutBuffer *buf); 157 void toDocBuffer(OutBuffer *buf);
146 158
147 PROT getAccess(Dsymbol *smember); // determine access to smember 159 PROT getAccess(Dsymbol *smember); // determine access to smember
148 160
161 #if IN_DMD
149 void toObjFile(int multiobj); // compile to .obj file 162 void toObjFile(int multiobj); // compile to .obj file
150 void toDt(dt_t **pdt); 163 void toDt(dt_t **pdt);
151 void toDebug(); // to symbolic debug info 164 void toDebug(); // to symbolic debug info
165 #endif
152 166
153 StructDeclaration *isStructDeclaration() { return this; } 167 StructDeclaration *isStructDeclaration() { return this; }
168
169 #if IN_LLVM
170 void codegen(Ir*);
171 #endif
154 }; 172 };
155 173
156 struct UnionDeclaration : StructDeclaration 174 struct UnionDeclaration : StructDeclaration
157 { 175 {
158 UnionDeclaration(Loc loc, Identifier *id); 176 UnionDeclaration(Loc loc, Identifier *id);
160 const char *kind(); 178 const char *kind();
161 179
162 UnionDeclaration *isUnionDeclaration() { return this; } 180 UnionDeclaration *isUnionDeclaration() { return this; }
163 }; 181 };
164 182
183 // warning: two classes with the same base class share the same
184 // BaseClass instance.
165 struct BaseClass 185 struct BaseClass
166 { 186 {
167 Type *type; // (before semantic processing) 187 Type *type; // (before semantic processing)
168 enum PROT protection; // protection for the base interface 188 enum PROT protection; // protection for the base interface
169 189
182 int fillVtbl(ClassDeclaration *cd, Array *vtbl, int newinstance); 202 int fillVtbl(ClassDeclaration *cd, Array *vtbl, int newinstance);
183 void copyBaseInterfaces(BaseClasses *); 203 void copyBaseInterfaces(BaseClasses *);
184 }; 204 };
185 205
186 #if DMDV2 206 #if DMDV2
187 #define CLASSINFO_SIZE (0x3C+16) // value of ClassInfo.size 207 #define CLASSINFO_SIZE (0x3C+16+4) // value of ClassInfo.size
188 #else 208 #else
189 #define CLASSINFO_SIZE (0x3C+12) // value of ClassInfo.size 209 #define CLASSINFO_SIZE (0x3C+12+4) // value of ClassInfo.size
190 #endif 210 #endif
191 211
192 struct ClassDeclaration : AggregateDeclaration 212 struct ClassDeclaration : AggregateDeclaration
193 { 213 {
194 static ClassDeclaration *object; 214 static ClassDeclaration *object;
214 int com; // !=0 if this is a COM class (meaning 234 int com; // !=0 if this is a COM class (meaning
215 // it derives from IUnknown) 235 // it derives from IUnknown)
216 int isauto; // !=0 if this is an auto class 236 int isauto; // !=0 if this is an auto class
217 int isabstract; // !=0 if abstract class 237 int isabstract; // !=0 if abstract class
218 238
219 int isnested; // !=0 if is nested
220 VarDeclaration *vthis; // 'this' parameter if this class is nested
221
222 int inuse; // to prevent recursive attempts 239 int inuse; // to prevent recursive attempts
223 240
224 ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses); 241 ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses);
225 Dsymbol *syntaxCopy(Dsymbol *s); 242 Dsymbol *syntaxCopy(Dsymbol *s);
226 void semantic(Scope *sc); 243 void semantic(Scope *sc);
234 #if DMDV2 251 #if DMDV2
235 int isFuncHidden(FuncDeclaration *fd); 252 int isFuncHidden(FuncDeclaration *fd);
236 #endif 253 #endif
237 FuncDeclaration *findFunc(Identifier *ident, TypeFunction *tf); 254 FuncDeclaration *findFunc(Identifier *ident, TypeFunction *tf);
238 void interfaceSemantic(Scope *sc); 255 void interfaceSemantic(Scope *sc);
239 int isNested();
240 int isCOMclass(); 256 int isCOMclass();
241 virtual int isCOMinterface(); 257 virtual int isCOMinterface();
242 #if DMDV2 258 #if DMDV2
243 virtual int isCPPinterface(); 259 virtual int isCPPinterface();
244 #endif 260 #endif
250 266
251 PROT getAccess(Dsymbol *smember); // determine access to smember 267 PROT getAccess(Dsymbol *smember); // determine access to smember
252 268
253 void addLocalClass(ClassDeclarations *); 269 void addLocalClass(ClassDeclarations *);
254 270
271 #if IN_DMD
255 // Back end 272 // Back end
256 void toObjFile(int multiobj); // compile to .obj file 273 void toObjFile(int multiobj); // compile to .obj file
257 void toDebug(); 274 void toDebug();
258 unsigned baseVtblOffset(BaseClass *bc); 275 unsigned baseVtblOffset(BaseClass *bc);
259 Symbol *toSymbol(); 276 Symbol *toSymbol();
260 Symbol *toVtblSymbol(); 277 Symbol *toVtblSymbol();
261 void toDt(dt_t **pdt); 278 void toDt(dt_t **pdt);
262 void toDt2(dt_t **pdt, ClassDeclaration *cd); 279 void toDt2(dt_t **pdt, ClassDeclaration *cd);
263 280
264 Symbol *vtblsym; 281 Symbol *vtblsym;
282 #endif
265 283
266 ClassDeclaration *isClassDeclaration() { return (ClassDeclaration *)this; } 284 ClassDeclaration *isClassDeclaration() { return (ClassDeclaration *)this; }
285
286 #if IN_LLVM
287 virtual void codegen(Ir*);
288 #endif
267 }; 289 };
268 290
269 struct InterfaceDeclaration : ClassDeclaration 291 struct InterfaceDeclaration : ClassDeclaration
270 { 292 {
271 #if DMDV2 293 #if DMDV2
281 #if DMDV2 303 #if DMDV2
282 int isCPPinterface(); 304 int isCPPinterface();
283 #endif 305 #endif
284 virtual int isCOMinterface(); 306 virtual int isCOMinterface();
285 307
308 #if IN_DMD
286 void toObjFile(int multiobj); // compile to .obj file 309 void toObjFile(int multiobj); // compile to .obj file
287 Symbol *toSymbol(); 310 Symbol *toSymbol();
311 #endif
288 312
289 InterfaceDeclaration *isInterfaceDeclaration() { return this; } 313 InterfaceDeclaration *isInterfaceDeclaration() { return this; }
314
315 #if IN_LLVM
316 void codegen(Ir*);
317 #endif
290 }; 318 };
291 319
292 #endif /* DMD_AGGREGATE_H */ 320 #endif /* DMD_AGGREGATE_H */