Mercurial > projects > ldc
annotate dmd/aggregate.h @ 149:4c577c2b7229 trunk
[svn r155] Fixed a bunch of linkage problems (especially with templates)
author | lindquist |
---|---|
date | Mon, 24 Mar 2008 19:43:02 +0100 |
parents | ce7b81fb957f |
children | ccd07d9f2ce9 |
rev | line source |
---|---|
1 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2006 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" | |
19 #include "dsymbol.h" | |
20 | |
8
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
1
diff
changeset
|
21 #include <vector> |
73 | 22 #include <set> |
23 #include <map> | |
8
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
1
diff
changeset
|
24 |
1 | 25 struct Identifier; |
26 struct Type; | |
27 struct TypeFunction; | |
28 struct Expression; | |
29 struct FuncDeclaration; | |
30 struct CtorDeclaration; | |
31 struct DtorDeclaration; | |
32 struct InvariantDeclaration; | |
33 struct NewDeclaration; | |
34 struct DeleteDeclaration; | |
35 struct InterfaceDeclaration; | |
36 struct ClassInfoDeclaration; | |
37 struct VarDeclaration; | |
38 struct dt_t; | |
39 | |
40 namespace llvm | |
41 { | |
42 class Type; | |
43 class Value; | |
44 class Constant; | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
35
diff
changeset
|
45 class ConstantStruct; |
100 | 46 class GlobalVariable; |
1 | 47 } |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
121
diff
changeset
|
48 struct IrStruct; |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
77
diff
changeset
|
49 struct DUnion; |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
77
diff
changeset
|
50 |
1 | 51 struct AggregateDeclaration : ScopeDsymbol |
52 { | |
53 Type *type; | |
54 unsigned storage_class; | |
55 enum PROT protection; | |
56 Type *handle; // 'this' type | |
57 unsigned structsize; // size of struct | |
58 unsigned alignsize; // size of struct for alignment purposes | |
59 unsigned structalign; // struct member alignment in effect | |
60 int hasUnions; // set if aggregate has overlapping fields | |
61 Array fields; // VarDeclaration fields | |
62 unsigned sizeok; // set when structsize contains valid data | |
63 // 0: no size | |
64 // 1: size is correct | |
65 // 2: cannot determine size; fwd referenced | |
66 int isdeprecated; // !=0 if deprecated | |
67 Scope *scope; // !=NULL means context to use | |
68 | |
69 // Special member functions | |
70 InvariantDeclaration *inv; // invariant | |
71 NewDeclaration *aggNew; // allocator | |
72 DeleteDeclaration *aggDelete; // deallocator | |
73 | |
74 #ifdef IN_GCC | |
75 Array methods; // flat list of all methods for debug information | |
76 #endif | |
77 | |
78 AggregateDeclaration(Loc loc, Identifier *id); | |
79 void semantic2(Scope *sc); | |
80 void semantic3(Scope *sc); | |
81 void inlineScan(); | |
82 unsigned size(Loc loc); | |
83 static void alignmember(unsigned salign, unsigned size, unsigned *poffset); | |
84 Type *getType(); | |
85 void addField(Scope *sc, VarDeclaration *v); | |
86 int isDeprecated(); // is aggregate deprecated? | |
87 | |
88 void emitComment(Scope *sc); | |
89 void toDocBuffer(OutBuffer *buf); | |
90 | |
91 // For access checking | |
92 virtual PROT getAccess(Dsymbol *smember); // determine access to smember | |
93 int isFriendOf(AggregateDeclaration *cd); | |
94 int hasPrivateAccess(Dsymbol *smember); // does smember have private access to members of this class? | |
95 void accessCheck(Loc loc, Scope *sc, Dsymbol *smember); | |
96 | |
97 enum PROT prot(); | |
98 | |
99 // Back end | |
100 Symbol *stag; // tag symbol for debug data | |
101 Symbol *sinit; | |
102 Symbol *toInitializer(); | |
103 | |
137 | 104 AggregateDeclaration *isAggregateDeclaration() { return this; } |
1 | 105 |
137 | 106 // llvmdc |
107 IrStruct* irStruct; | |
1 | 108 }; |
109 | |
110 struct AnonymousAggregateDeclaration : AggregateDeclaration | |
111 { | |
112 AnonymousAggregateDeclaration() | |
113 : AggregateDeclaration(0, NULL) | |
114 { | |
115 } | |
116 | |
117 AnonymousAggregateDeclaration *isAnonymousAggregateDeclaration() { return this; } | |
118 }; | |
119 | |
120 struct StructDeclaration : AggregateDeclaration | |
121 { | |
122 int zeroInit; // !=0 if initialize with 0 fill | |
123 | |
124 StructDeclaration(Loc loc, Identifier *id); | |
125 Dsymbol *syntaxCopy(Dsymbol *s); | |
126 void semantic(Scope *sc); | |
127 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
128 char *mangle(); | |
129 char *kind(); | |
130 void toDocBuffer(OutBuffer *buf); | |
131 | |
132 PROT getAccess(Dsymbol *smember); // determine access to smember | |
133 | |
134 void toObjFile(); // compile to .obj file | |
135 void toDt(dt_t **pdt); | |
136 void toDebug(); // to symbolic debug info | |
137 | |
138 StructDeclaration *isStructDeclaration() { return this; } | |
139 }; | |
140 | |
141 struct UnionDeclaration : StructDeclaration | |
142 { | |
143 UnionDeclaration(Loc loc, Identifier *id); | |
144 Dsymbol *syntaxCopy(Dsymbol *s); | |
145 char *kind(); | |
146 | |
147 UnionDeclaration *isUnionDeclaration() { return this; } | |
148 }; | |
149 | |
150 struct BaseClass | |
151 { | |
152 Type *type; // (before semantic processing) | |
153 enum PROT protection; // protection for the base interface | |
154 | |
155 ClassDeclaration *base; | |
156 int offset; // 'this' pointer offset | |
157 Array vtbl; // for interfaces: Array of FuncDeclaration's | |
158 // making up the vtbl[] | |
159 | |
160 int baseInterfaces_dim; | |
161 BaseClass *baseInterfaces; // if BaseClass is an interface, these | |
162 // are a copy of the InterfaceDeclaration::interfaces | |
163 | |
164 BaseClass(); | |
165 BaseClass(Type *type, enum PROT protection); | |
166 | |
167 int fillVtbl(ClassDeclaration *cd, Array *vtbl, int newinstance); | |
168 void copyBaseInterfaces(BaseClasses *); | |
169 }; | |
170 | |
171 #define CLASSINFO_SIZE (0x3C+12) // value of ClassInfo.size | |
172 | |
173 struct ClassDeclaration : AggregateDeclaration | |
174 { | |
175 static ClassDeclaration *object; | |
176 static ClassDeclaration *classinfo; | |
177 | |
178 ClassDeclaration *baseClass; // NULL only if this is Object | |
179 CtorDeclaration *ctor; | |
180 CtorDeclaration *defaultCtor; // default constructor | |
181 FuncDeclarations dtors; // Array of destructors | |
182 FuncDeclaration *staticCtor; | |
183 FuncDeclaration *staticDtor; | |
184 Array vtbl; // Array of FuncDeclaration's making up the vtbl[] | |
185 Array vtblFinal; // More FuncDeclaration's that aren't in vtbl[] | |
186 | |
187 BaseClasses baseclasses; // Array of BaseClass's; first is super, | |
188 // rest are Interface's | |
189 | |
190 int interfaces_dim; | |
191 BaseClass **interfaces; // interfaces[interfaces_dim] for this class | |
192 // (does not include baseClass) | |
193 | |
194 BaseClasses *vtblInterfaces; // array of base interfaces that have | |
195 // their own vtbl[] | |
196 | |
197 ClassInfoDeclaration *vclassinfo; // the ClassInfo object for this ClassDeclaration | |
198 int com; // !=0 if this is a COM class | |
199 int isauto; // !=0 if this is an auto class | |
200 int isabstract; // !=0 if abstract class | |
201 | |
202 int isnested; // !=0 if is nested | |
203 VarDeclaration *vthis; // 'this' parameter if this class is nested | |
204 | |
205 ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses); | |
206 Dsymbol *syntaxCopy(Dsymbol *s); | |
207 void semantic(Scope *sc); | |
208 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
209 int isBaseOf2(ClassDeclaration *cd); | |
210 | |
211 #define OFFSET_RUNTIME 0x76543210 | |
212 virtual int isBaseOf(ClassDeclaration *cd, int *poffset); | |
213 | |
214 Dsymbol *search(Loc, Identifier *ident, int flags); | |
215 FuncDeclaration *findFunc(Identifier *ident, TypeFunction *tf); | |
216 void interfaceSemantic(Scope *sc); | |
217 int isNested(); | |
218 int isCOMclass(); | |
35
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
24
diff
changeset
|
219 virtual int isCOMinterface(); |
1 | 220 int isAbstract(); |
221 virtual int vtblOffset(); | |
222 char *kind(); | |
223 char *mangle(); | |
224 void toDocBuffer(OutBuffer *buf); | |
225 | |
226 PROT getAccess(Dsymbol *smember); // determine access to smember | |
227 | |
228 void addLocalClass(ClassDeclarations *); | |
229 | |
230 // Back end | |
231 void toObjFile(); // compile to .obj file | |
232 void toDebug(); | |
233 unsigned baseVtblOffset(BaseClass *bc); | |
234 Symbol *toSymbol(); | |
235 Symbol *toVtblSymbol(); | |
236 void toDt(dt_t **pdt); | |
237 void toDt2(dt_t **pdt, ClassDeclaration *cd); | |
238 | |
239 Symbol *vtblsym; | |
240 | |
77
714057ff2dbb
[svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents:
73
diff
changeset
|
241 void offsetToIndex(Type* t, unsigned os, std::vector<unsigned>& result); |
1 | 242 |
243 ClassDeclaration *isClassDeclaration() { return (ClassDeclaration *)this; } | |
244 }; | |
245 | |
246 struct InterfaceDeclaration : ClassDeclaration | |
247 { | |
248 InterfaceDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses); | |
249 Dsymbol *syntaxCopy(Dsymbol *s); | |
250 void semantic(Scope *sc); | |
251 int isBaseOf(ClassDeclaration *cd, int *poffset); | |
252 int isBaseOf(BaseClass *bc, int *poffset); | |
253 char *kind(); | |
254 int vtblOffset(); | |
35
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
24
diff
changeset
|
255 virtual int isCOMinterface(); |
1 | 256 |
257 void toObjFile(); // compile to .obj file | |
258 Symbol *toSymbol(); | |
259 | |
260 InterfaceDeclaration *isInterfaceDeclaration() { return this; } | |
261 }; | |
262 | |
263 #endif /* DMD_AGGREGATE_H */ |