Mercurial > projects > ldc
annotate dmd/aggregate.h @ 156:ccd07d9f2ce9 trunk
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
author | ChristianK |
---|---|
date | Thu, 01 May 2008 13:05:53 +0200 |
parents | ce7b81fb957f |
children | 5acec6b2eef8 |
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 } |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
77
diff
changeset
|
48 struct DUnion; |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
77
diff
changeset
|
49 |
1 | 50 struct AggregateDeclaration : ScopeDsymbol |
51 { | |
52 Type *type; | |
53 unsigned storage_class; | |
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 Scope *scope; // !=NULL means context to use | |
67 | |
68 // Special member functions | |
69 InvariantDeclaration *inv; // invariant | |
70 NewDeclaration *aggNew; // allocator | |
71 DeleteDeclaration *aggDelete; // deallocator | |
72 | |
73 #ifdef IN_GCC | |
74 Array methods; // flat list of all methods for debug information | |
75 #endif | |
76 | |
77 AggregateDeclaration(Loc loc, Identifier *id); | |
78 void semantic2(Scope *sc); | |
79 void semantic3(Scope *sc); | |
80 void inlineScan(); | |
81 unsigned size(Loc loc); | |
82 static void alignmember(unsigned salign, unsigned size, unsigned *poffset); | |
83 Type *getType(); | |
84 void addField(Scope *sc, VarDeclaration *v); | |
85 int isDeprecated(); // is aggregate deprecated? | |
86 | |
87 void emitComment(Scope *sc); | |
88 void toDocBuffer(OutBuffer *buf); | |
89 | |
90 // For access checking | |
91 virtual PROT getAccess(Dsymbol *smember); // determine access to smember | |
92 int isFriendOf(AggregateDeclaration *cd); | |
93 int hasPrivateAccess(Dsymbol *smember); // does smember have private access to members of this class? | |
94 void accessCheck(Loc loc, Scope *sc, Dsymbol *smember); | |
95 | |
96 enum PROT prot(); | |
97 | |
98 // Back end | |
99 Symbol *stag; // tag symbol for debug data | |
100 Symbol *sinit; | |
101 Symbol *toInitializer(); | |
102 | |
137 | 103 AggregateDeclaration *isAggregateDeclaration() { return this; } |
1 | 104 }; |
105 | |
106 struct AnonymousAggregateDeclaration : AggregateDeclaration | |
107 { | |
108 AnonymousAggregateDeclaration() | |
109 : AggregateDeclaration(0, NULL) | |
110 { | |
111 } | |
112 | |
113 AnonymousAggregateDeclaration *isAnonymousAggregateDeclaration() { return this; } | |
114 }; | |
115 | |
116 struct StructDeclaration : AggregateDeclaration | |
117 { | |
118 int zeroInit; // !=0 if initialize with 0 fill | |
119 | |
120 StructDeclaration(Loc loc, Identifier *id); | |
121 Dsymbol *syntaxCopy(Dsymbol *s); | |
122 void semantic(Scope *sc); | |
123 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
124 char *mangle(); | |
125 char *kind(); | |
126 void toDocBuffer(OutBuffer *buf); | |
127 | |
128 PROT getAccess(Dsymbol *smember); // determine access to smember | |
129 | |
130 void toObjFile(); // compile to .obj file | |
131 void toDt(dt_t **pdt); | |
132 void toDebug(); // to symbolic debug info | |
133 | |
134 StructDeclaration *isStructDeclaration() { return this; } | |
135 }; | |
136 | |
137 struct UnionDeclaration : StructDeclaration | |
138 { | |
139 UnionDeclaration(Loc loc, Identifier *id); | |
140 Dsymbol *syntaxCopy(Dsymbol *s); | |
141 char *kind(); | |
142 | |
143 UnionDeclaration *isUnionDeclaration() { return this; } | |
144 }; | |
145 | |
146 struct BaseClass | |
147 { | |
148 Type *type; // (before semantic processing) | |
149 enum PROT protection; // protection for the base interface | |
150 | |
151 ClassDeclaration *base; | |
152 int offset; // 'this' pointer offset | |
153 Array vtbl; // for interfaces: Array of FuncDeclaration's | |
154 // making up the vtbl[] | |
155 | |
156 int baseInterfaces_dim; | |
157 BaseClass *baseInterfaces; // if BaseClass is an interface, these | |
158 // are a copy of the InterfaceDeclaration::interfaces | |
159 | |
160 BaseClass(); | |
161 BaseClass(Type *type, enum PROT protection); | |
162 | |
163 int fillVtbl(ClassDeclaration *cd, Array *vtbl, int newinstance); | |
164 void copyBaseInterfaces(BaseClasses *); | |
165 }; | |
166 | |
167 #define CLASSINFO_SIZE (0x3C+12) // value of ClassInfo.size | |
168 | |
169 struct ClassDeclaration : AggregateDeclaration | |
170 { | |
171 static ClassDeclaration *object; | |
172 static ClassDeclaration *classinfo; | |
173 | |
174 ClassDeclaration *baseClass; // NULL only if this is Object | |
175 CtorDeclaration *ctor; | |
176 CtorDeclaration *defaultCtor; // default constructor | |
177 FuncDeclarations dtors; // Array of destructors | |
178 FuncDeclaration *staticCtor; | |
179 FuncDeclaration *staticDtor; | |
180 Array vtbl; // Array of FuncDeclaration's making up the vtbl[] | |
181 Array vtblFinal; // More FuncDeclaration's that aren't in vtbl[] | |
182 | |
183 BaseClasses baseclasses; // Array of BaseClass's; first is super, | |
184 // rest are Interface's | |
185 | |
186 int interfaces_dim; | |
187 BaseClass **interfaces; // interfaces[interfaces_dim] for this class | |
188 // (does not include baseClass) | |
189 | |
190 BaseClasses *vtblInterfaces; // array of base interfaces that have | |
191 // their own vtbl[] | |
192 | |
193 ClassInfoDeclaration *vclassinfo; // the ClassInfo object for this ClassDeclaration | |
194 int com; // !=0 if this is a COM class | |
195 int isauto; // !=0 if this is an auto class | |
196 int isabstract; // !=0 if abstract class | |
197 | |
198 int isnested; // !=0 if is nested | |
199 VarDeclaration *vthis; // 'this' parameter if this class is nested | |
200 | |
201 ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses); | |
202 Dsymbol *syntaxCopy(Dsymbol *s); | |
203 void semantic(Scope *sc); | |
204 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
205 int isBaseOf2(ClassDeclaration *cd); | |
206 | |
207 #define OFFSET_RUNTIME 0x76543210 | |
208 virtual int isBaseOf(ClassDeclaration *cd, int *poffset); | |
209 | |
210 Dsymbol *search(Loc, Identifier *ident, int flags); | |
211 FuncDeclaration *findFunc(Identifier *ident, TypeFunction *tf); | |
212 void interfaceSemantic(Scope *sc); | |
213 int isNested(); | |
214 int isCOMclass(); | |
35
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
24
diff
changeset
|
215 virtual int isCOMinterface(); |
1 | 216 int isAbstract(); |
217 virtual int vtblOffset(); | |
218 char *kind(); | |
219 char *mangle(); | |
220 void toDocBuffer(OutBuffer *buf); | |
221 | |
222 PROT getAccess(Dsymbol *smember); // determine access to smember | |
223 | |
224 void addLocalClass(ClassDeclarations *); | |
225 | |
226 // Back end | |
227 void toObjFile(); // compile to .obj file | |
228 void toDebug(); | |
229 unsigned baseVtblOffset(BaseClass *bc); | |
230 Symbol *toSymbol(); | |
231 Symbol *toVtblSymbol(); | |
232 void toDt(dt_t **pdt); | |
233 void toDt2(dt_t **pdt, ClassDeclaration *cd); | |
234 | |
235 Symbol *vtblsym; | |
236 | |
77
714057ff2dbb
[svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents:
73
diff
changeset
|
237 void offsetToIndex(Type* t, unsigned os, std::vector<unsigned>& result); |
1 | 238 |
239 ClassDeclaration *isClassDeclaration() { return (ClassDeclaration *)this; } | |
240 }; | |
241 | |
242 struct InterfaceDeclaration : ClassDeclaration | |
243 { | |
244 InterfaceDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses); | |
245 Dsymbol *syntaxCopy(Dsymbol *s); | |
246 void semantic(Scope *sc); | |
247 int isBaseOf(ClassDeclaration *cd, int *poffset); | |
248 int isBaseOf(BaseClass *bc, int *poffset); | |
249 char *kind(); | |
250 int vtblOffset(); | |
35
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
24
diff
changeset
|
251 virtual int isCOMinterface(); |
1 | 252 |
253 void toObjFile(); // compile to .obj file | |
254 Symbol *toSymbol(); | |
255 | |
256 InterfaceDeclaration *isInterfaceDeclaration() { return this; } | |
257 }; | |
258 | |
259 #endif /* DMD_AGGREGATE_H */ |