Mercurial > projects > ldc
annotate dmd/dsymbol.h @ 1536:49ae9728bea4
Check for ldc.conf next to the ldc binary before home and etc.
The new search order is
* current working directory
* next to executable
* user home directory
* prefix/etc
* prefix/etc/ldc
* /etc
* /etc/ldc
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Mon, 13 Jul 2009 22:24:12 +0200 |
parents | 229e02867307 |
children | def7a1d494fd |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
336 | 3 // Copyright (c) 1999-2008 by Digital Mars |
159 | 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_DSYMBOL_H | |
12 #define DMD_DSYMBOL_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include "root.h" | |
19 #include "stringtable.h" | |
20 | |
21 #include "mars.h" | |
22 #include "arraytypes.h" | |
23 | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
159
diff
changeset
|
24 // llvm |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
25 #include "../ir/irdsymbol.h" |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
159
diff
changeset
|
26 |
159 | 27 struct Identifier; |
28 struct Scope; | |
29 struct DsymbolTable; | |
30 struct Declaration; | |
31 struct TupleDeclaration; | |
32 struct TypedefDeclaration; | |
33 struct AliasDeclaration; | |
34 struct AggregateDeclaration; | |
35 struct EnumDeclaration; | |
36 struct ClassDeclaration; | |
37 struct InterfaceDeclaration; | |
38 struct StructDeclaration; | |
39 struct UnionDeclaration; | |
40 struct FuncDeclaration; | |
41 struct FuncAliasDeclaration; | |
42 struct FuncLiteralDeclaration; | |
43 struct CtorDeclaration; | |
44 struct DtorDeclaration; | |
45 struct StaticCtorDeclaration; | |
46 struct StaticDtorDeclaration; | |
47 struct InvariantDeclaration; | |
48 struct UnitTestDeclaration; | |
49 struct NewDeclaration; | |
50 struct VarDeclaration; | |
51 struct AttribDeclaration; | |
52 struct Package; | |
53 struct Module; | |
54 struct Import; | |
55 struct Type; | |
56 struct TypeTuple; | |
57 struct WithStatement; | |
58 struct LabelDsymbol; | |
59 struct ScopeDsymbol; | |
60 struct TemplateDeclaration; | |
61 struct TemplateInstance; | |
62 struct TemplateMixin; | |
63 struct EnumMember; | |
64 struct ScopeDsymbol; | |
65 struct WithScopeSymbol; | |
66 struct ArrayScopeSymbol; | |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
67 struct StaticStructInitDeclaration; |
159 | 68 struct Expression; |
69 struct DeleteDeclaration; | |
70 struct HdrGenState; | |
71 struct TypeInfoDeclaration; | |
72 struct ClassInfoDeclaration; | |
73 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
74 #if IN_DMD |
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
75 struct Symbol; |
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
76 #endif |
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
77 |
159 | 78 #if IN_GCC |
79 union tree_node; | |
80 typedef union tree_node TYPE; | |
81 #else | |
82 struct TYPE; | |
83 #endif | |
84 | |
85 #if IN_LLVM | |
1364
46f6365a50d7
Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1147
diff
changeset
|
86 class Ir; |
46f6365a50d7
Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1147
diff
changeset
|
87 class IrSymbol; |
159 | 88 namespace llvm |
89 { | |
90 class Value; | |
91 } | |
92 #endif | |
93 | |
94 enum PROT | |
95 { | |
96 PROTundefined, | |
97 PROTnone, // no access | |
98 PROTprivate, | |
99 PROTpackage, | |
100 PROTprotected, | |
101 PROTpublic, | |
102 PROTexport, | |
103 }; | |
104 | |
105 | |
106 struct Dsymbol : Object | |
107 { | |
108 Identifier *ident; | |
109 Identifier *c_ident; | |
110 Dsymbol *parent; | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
111 #if IN_DMD |
159 | 112 Symbol *csym; // symbol for code generator |
113 Symbol *isym; // import version of csym | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
114 #endif |
159 | 115 unsigned char *comment; // documentation comment for this Dsymbol |
116 Loc loc; // where defined | |
117 | |
118 Dsymbol(); | |
119 Dsymbol(Identifier *); | |
120 char *toChars(); | |
121 char *toPrettyChars(); | |
122 char *locToChars(); | |
123 int equals(Object *o); | |
124 int isAnonymous(); | |
1372
229e02867307
Fix format-string bugs by adding __attribute__((__format__)) in all applicable
Frits van Bommel <fvbommel wxs.nl>
parents:
1364
diff
changeset
|
125 void error(Loc loc, const char *format, ...) IS_PRINTF(3); |
229e02867307
Fix format-string bugs by adding __attribute__((__format__)) in all applicable
Frits van Bommel <fvbommel wxs.nl>
parents:
1364
diff
changeset
|
126 void error(const char *format, ...) IS_PRINTF(2); |
159 | 127 void checkDeprecated(Loc loc, Scope *sc); |
946
1714836f2c0b
Mostly rewrite debug info generation in terms of llvm/Analysis/DebugInfo.h.
Christian Kamm <kamm incasoftware de>
parents:
913
diff
changeset
|
128 Module *getModule(); // module where declared |
1714836f2c0b
Mostly rewrite debug info generation in terms of llvm/Analysis/DebugInfo.h.
Christian Kamm <kamm incasoftware de>
parents:
913
diff
changeset
|
129 Module *getCompilationModule(); // possibly different for templates |
159 | 130 Dsymbol *pastMixin(); |
131 Dsymbol *toParent(); | |
132 Dsymbol *toParent2(); | |
336 | 133 TemplateInstance *inTemplateInstance(); |
159 | 134 |
135 int dyncast() { return DYNCAST_DSYMBOL; } // kludge for template.isSymbol() | |
136 | |
137 static Array *arraySyntaxCopy(Array *a); | |
138 | |
336 | 139 virtual const char *kind(); |
159 | 140 virtual Dsymbol *toAlias(); // resolve real symbol |
141 virtual int addMember(Scope *sc, ScopeDsymbol *s, int memnum); | |
142 virtual void semantic(Scope *sc); | |
143 virtual void semantic2(Scope *sc); | |
144 virtual void semantic3(Scope *sc); | |
145 virtual void inlineScan(); | |
146 virtual Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
147 Dsymbol *searchX(Loc loc, Scope *sc, Identifier *id); | |
148 virtual int overloadInsert(Dsymbol *s); | |
149 #ifdef _DH | |
150 char *toHChars(); | |
151 virtual void toHBuffer(OutBuffer *buf, HdrGenState *hgs); | |
152 #endif | |
153 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
154 virtual void toDocBuffer(OutBuffer *buf); | |
155 virtual unsigned size(Loc loc); | |
156 virtual int isforwardRef(); | |
157 virtual void defineRef(Dsymbol *s); | |
158 virtual AggregateDeclaration *isThis(); // is a 'this' required to access the member | |
159 virtual ClassDeclaration *isClassMember(); // are we a member of a class? | |
160 virtual int isExport(); // is Dsymbol exported? | |
336 | 161 virtual int isImportedSymbol(); // is Dsymbol imported? |
159 | 162 virtual int isDeprecated(); // is Dsymbol deprecated? |
163 virtual LabelDsymbol *isLabel(); // is this a LabelDsymbol? | |
164 virtual AggregateDeclaration *isMember(); // is this symbol a member of an AggregateDeclaration? | |
165 virtual Type *getType(); // is this a type? | |
166 virtual char *mangle(); | |
167 virtual int needThis(); // need a 'this' pointer? | |
168 virtual enum PROT prot(); | |
169 virtual Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees | |
170 virtual int oneMember(Dsymbol **ps); | |
171 static int oneMembers(Array *members, Dsymbol **ps); | |
172 virtual int hasPointers(); | |
173 virtual void addLocalClass(ClassDeclarations *) { } | |
174 virtual void checkCtorConstInit() { } | |
175 | |
176 virtual void addComment(unsigned char *comment); | |
177 virtual void emitComment(Scope *sc); | |
178 void emitDitto(Scope *sc); | |
179 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
180 #if IN_DMD |
159 | 181 // Backend |
182 | |
183 virtual Symbol *toSymbol(); // to backend symbol | |
336 | 184 virtual void toObjFile(int multiobj); // compile to .obj file |
159 | 185 virtual int cvMember(unsigned char *p); // emit cv debug info for member |
186 | |
187 Symbol *toImport(); // to backend import symbol | |
188 static Symbol *toImport(Symbol *s); // to backend import symbol | |
189 | |
190 Symbol *toSymbolX(const char *prefix, int sclass, TYPE *t, const char *suffix); // helper | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
191 #endif |
159 | 192 |
193 // Eliminate need for dynamic_cast | |
194 virtual Package *isPackage() { return NULL; } | |
195 virtual Module *isModule() { return NULL; } | |
196 virtual EnumMember *isEnumMember() { return NULL; } | |
197 virtual TemplateDeclaration *isTemplateDeclaration() { return NULL; } | |
198 virtual TemplateInstance *isTemplateInstance() { return NULL; } | |
199 virtual TemplateMixin *isTemplateMixin() { return NULL; } | |
200 virtual Declaration *isDeclaration() { return NULL; } | |
201 virtual TupleDeclaration *isTupleDeclaration() { return NULL; } | |
202 virtual TypedefDeclaration *isTypedefDeclaration() { return NULL; } | |
203 virtual AliasDeclaration *isAliasDeclaration() { return NULL; } | |
204 virtual AggregateDeclaration *isAggregateDeclaration() { return NULL; } | |
205 virtual FuncDeclaration *isFuncDeclaration() { return NULL; } | |
206 virtual FuncAliasDeclaration *isFuncAliasDeclaration() { return NULL; } | |
207 virtual FuncLiteralDeclaration *isFuncLiteralDeclaration() { return NULL; } | |
208 virtual CtorDeclaration *isCtorDeclaration() { return NULL; } | |
209 virtual DtorDeclaration *isDtorDeclaration() { return NULL; } | |
210 virtual StaticCtorDeclaration *isStaticCtorDeclaration() { return NULL; } | |
211 virtual StaticDtorDeclaration *isStaticDtorDeclaration() { return NULL; } | |
212 virtual InvariantDeclaration *isInvariantDeclaration() { return NULL; } | |
213 virtual UnitTestDeclaration *isUnitTestDeclaration() { return NULL; } | |
214 virtual NewDeclaration *isNewDeclaration() { return NULL; } | |
215 virtual VarDeclaration *isVarDeclaration() { return NULL; } | |
216 virtual ClassDeclaration *isClassDeclaration() { return NULL; } | |
217 virtual StructDeclaration *isStructDeclaration() { return NULL; } | |
218 virtual UnionDeclaration *isUnionDeclaration() { return NULL; } | |
219 virtual InterfaceDeclaration *isInterfaceDeclaration() { return NULL; } | |
220 virtual ScopeDsymbol *isScopeDsymbol() { return NULL; } | |
221 virtual WithScopeSymbol *isWithScopeSymbol() { return NULL; } | |
222 virtual ArrayScopeSymbol *isArrayScopeSymbol() { return NULL; } | |
223 virtual Import *isImport() { return NULL; } | |
224 virtual EnumDeclaration *isEnumDeclaration() { return NULL; } | |
225 #ifdef _DH | |
226 virtual DeleteDeclaration *isDeleteDeclaration() { return NULL; } | |
227 #endif | |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
228 virtual StaticStructInitDeclaration *isStaticStructInitDeclaration() { return NULL; } |
159 | 229 virtual AttribDeclaration *isAttribDeclaration() { return NULL; } |
230 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return NULL; } | |
231 virtual ClassInfoDeclaration* isClassInfoDeclaration() { return NULL; } | |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
232 |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
233 #if IN_LLVM |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
234 /// Codegen traversal |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
235 virtual void codegen(Ir* ir); |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
236 |
159 | 237 // llvm stuff |
238 int llvmInternal; | |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
239 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
159
diff
changeset
|
240 IrDsymbol ir; |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
241 IrSymbol* irsym; |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
242 #endif |
159 | 243 }; |
244 | |
245 // Dsymbol that generates a scope | |
246 | |
247 struct ScopeDsymbol : Dsymbol | |
248 { | |
249 Array *members; // all Dsymbol's in this scope | |
250 DsymbolTable *symtab; // members[] sorted into table | |
251 | |
252 Array *imports; // imported ScopeDsymbol's | |
253 unsigned char *prots; // PROT for each import | |
254 | |
255 ScopeDsymbol(); | |
256 ScopeDsymbol(Identifier *id); | |
257 Dsymbol *syntaxCopy(Dsymbol *s); | |
258 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
259 void importScope(ScopeDsymbol *s, enum PROT protection); | |
260 int isforwardRef(); | |
261 void defineRef(Dsymbol *s); | |
262 static void multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2); | |
263 Dsymbol *nameCollision(Dsymbol *s); | |
336 | 264 const char *kind(); |
159 | 265 |
266 void emitMemberComments(Scope *sc); | |
267 | |
268 ScopeDsymbol *isScopeDsymbol() { return this; } | |
269 }; | |
270 | |
271 // With statement scope | |
272 | |
273 struct WithScopeSymbol : ScopeDsymbol | |
274 { | |
275 WithStatement *withstate; | |
276 | |
277 WithScopeSymbol(WithStatement *withstate); | |
278 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
279 | |
280 WithScopeSymbol *isWithScopeSymbol() { return this; } | |
281 }; | |
282 | |
283 // Array Index/Slice scope | |
284 | |
285 struct ArrayScopeSymbol : ScopeDsymbol | |
286 { | |
287 Expression *exp; // IndexExp or SliceExp | |
288 TypeTuple *type; // for tuple[length] | |
289 TupleDeclaration *td; // for tuples of objects | |
290 | |
291 ArrayScopeSymbol(Expression *e); | |
292 ArrayScopeSymbol(TypeTuple *t); | |
293 ArrayScopeSymbol(TupleDeclaration *td); | |
294 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
295 | |
296 ArrayScopeSymbol *isArrayScopeSymbol() { return this; } | |
297 }; | |
298 | |
299 // Table of Dsymbol's | |
300 | |
301 struct DsymbolTable : Object | |
302 { | |
303 StringTable *tab; | |
304 | |
305 DsymbolTable(); | |
306 ~DsymbolTable(); | |
307 | |
308 // Look up Identifier. Return Dsymbol if found, NULL if not. | |
309 Dsymbol *lookup(Identifier *ident); | |
310 | |
311 // Insert Dsymbol in table. Return NULL if already there. | |
312 Dsymbol *insert(Dsymbol *s); | |
313 | |
314 // Look for Dsymbol in table. If there, return it. If not, insert s and return that. | |
315 Dsymbol *update(Dsymbol *s); | |
316 Dsymbol *insert(Identifier *ident, Dsymbol *s); // when ident and s are not the same | |
317 }; | |
318 | |
319 #endif /* DMD_DSYMBOL_H */ |