Mercurial > projects > ldc
annotate dmd/dsymbol.h @ 1641:00cd99bedf06
Add missing files for the new frontend spell checker
author | Kelly Wilson <wilsonk cpsc.ucalgary.ca> |
---|---|
date | Mon, 08 Mar 2010 17:41:36 -0700 |
parents | 9bf06e02070b |
children |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
1640 | 3 // Copyright (c) 1999-2010 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 | |
1630
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
24 #if IN_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" |
1630
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
26 #endif |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
159
diff
changeset
|
27 |
159 | 28 struct Identifier; |
29 struct Scope; | |
30 struct DsymbolTable; | |
31 struct Declaration; | |
1587 | 32 struct ThisDeclaration; |
159 | 33 struct TupleDeclaration; |
34 struct TypedefDeclaration; | |
35 struct AliasDeclaration; | |
36 struct AggregateDeclaration; | |
37 struct EnumDeclaration; | |
38 struct ClassDeclaration; | |
39 struct InterfaceDeclaration; | |
40 struct StructDeclaration; | |
41 struct UnionDeclaration; | |
42 struct FuncDeclaration; | |
43 struct FuncAliasDeclaration; | |
44 struct FuncLiteralDeclaration; | |
45 struct CtorDeclaration; | |
1587 | 46 struct PostBlitDeclaration; |
159 | 47 struct DtorDeclaration; |
48 struct StaticCtorDeclaration; | |
49 struct StaticDtorDeclaration; | |
50 struct InvariantDeclaration; | |
51 struct UnitTestDeclaration; | |
52 struct NewDeclaration; | |
53 struct VarDeclaration; | |
54 struct AttribDeclaration; | |
1630
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
55 #if IN_DMD |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
56 struct Symbol; |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
57 #endif |
159 | 58 struct Package; |
59 struct Module; | |
60 struct Import; | |
61 struct Type; | |
62 struct TypeTuple; | |
63 struct WithStatement; | |
64 struct LabelDsymbol; | |
65 struct ScopeDsymbol; | |
66 struct TemplateDeclaration; | |
67 struct TemplateInstance; | |
68 struct TemplateMixin; | |
69 struct EnumMember; | |
70 struct ScopeDsymbol; | |
71 struct WithScopeSymbol; | |
72 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
|
73 struct StaticStructInitDeclaration; |
159 | 74 struct Expression; |
75 struct DeleteDeclaration; | |
76 struct HdrGenState; | |
77 struct TypeInfoDeclaration; | |
78 struct ClassInfoDeclaration; | |
1587 | 79 struct OverloadSet; |
80 #if TARGET_NET | |
81 struct PragmaScope; | |
82 #endif | |
159 | 83 #if IN_GCC |
84 union tree_node; | |
85 typedef union tree_node TYPE; | |
86 #else | |
87 struct TYPE; | |
88 #endif | |
89 | |
1587 | 90 // Back end |
91 struct Classsym; | |
92 | |
159 | 93 #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
|
94 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
|
95 class IrSymbol; |
159 | 96 namespace llvm |
97 { | |
98 class Value; | |
99 } | |
100 #endif | |
101 | |
102 enum PROT | |
103 { | |
104 PROTundefined, | |
105 PROTnone, // no access | |
106 PROTprivate, | |
107 PROTpackage, | |
108 PROTprotected, | |
109 PROTpublic, | |
110 PROTexport, | |
111 }; | |
112 | |
1630
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
113 /* State of symbol in winding its way through the passes of the compiler |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
114 */ |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
115 enum PASS |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
116 { |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
117 PASSinit, // initial state |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
118 PASSsemantic, // semantic() started |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
119 PASSsemanticdone, // semantic() done |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
120 PASSsemantic2, // semantic2() run |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
121 PASSsemantic3, // semantic3() started |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
122 PASSsemantic3done, // semantic3() done |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
123 PASSobj, // toObjFile() run |
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
124 }; |
159 | 125 |
126 struct Dsymbol : Object | |
127 { | |
128 Identifier *ident; | |
129 Identifier *c_ident; | |
130 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
|
131 #if IN_DMD |
159 | 132 Symbol *csym; // symbol for code generator |
133 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
|
134 #endif |
159 | 135 unsigned char *comment; // documentation comment for this Dsymbol |
136 Loc loc; // where defined | |
1587 | 137 Scope *scope; // !=NULL means context to use for semantic() |
159 | 138 |
139 Dsymbol(); | |
140 Dsymbol(Identifier *); | |
141 char *toChars(); | |
142 char *locToChars(); | |
143 int equals(Object *o); | |
144 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
|
145 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
|
146 void error(const char *format, ...) IS_PRINTF(2); |
159 | 147 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
|
148 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
|
149 Module *getCompilationModule(); // possibly different for templates |
159 | 150 Dsymbol *pastMixin(); |
151 Dsymbol *toParent(); | |
152 Dsymbol *toParent2(); | |
336 | 153 TemplateInstance *inTemplateInstance(); |
159 | 154 |
155 int dyncast() { return DYNCAST_DSYMBOL; } // kludge for template.isSymbol() | |
156 | |
157 static Array *arraySyntaxCopy(Array *a); | |
158 | |
1587 | 159 virtual const char *toPrettyChars(); |
336 | 160 virtual const char *kind(); |
159 | 161 virtual Dsymbol *toAlias(); // resolve real symbol |
162 virtual int addMember(Scope *sc, ScopeDsymbol *s, int memnum); | |
1587 | 163 virtual void setScope(Scope *sc); |
164 virtual void importAll(Scope *sc); | |
159 | 165 virtual void semantic(Scope *sc); |
166 virtual void semantic2(Scope *sc); | |
167 virtual void semantic3(Scope *sc); | |
168 virtual void inlineScan(); | |
169 virtual Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
1640 | 170 Dsymbol *search_correct(Identifier *id); |
159 | 171 Dsymbol *searchX(Loc loc, Scope *sc, Identifier *id); |
172 virtual int overloadInsert(Dsymbol *s); | |
173 #ifdef _DH | |
174 char *toHChars(); | |
175 virtual void toHBuffer(OutBuffer *buf, HdrGenState *hgs); | |
176 #endif | |
177 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
178 virtual void toDocBuffer(OutBuffer *buf); | |
1587 | 179 virtual void toJsonBuffer(OutBuffer *buf); |
159 | 180 virtual unsigned size(Loc loc); |
181 virtual int isforwardRef(); | |
182 virtual void defineRef(Dsymbol *s); | |
183 virtual AggregateDeclaration *isThis(); // is a 'this' required to access the member | |
184 virtual ClassDeclaration *isClassMember(); // are we a member of a class? | |
185 virtual int isExport(); // is Dsymbol exported? | |
336 | 186 virtual int isImportedSymbol(); // is Dsymbol imported? |
159 | 187 virtual int isDeprecated(); // is Dsymbol deprecated? |
1587 | 188 #if DMDV2 |
189 virtual int isOverloadable(); | |
190 #endif | |
159 | 191 virtual LabelDsymbol *isLabel(); // is this a LabelDsymbol? |
192 virtual AggregateDeclaration *isMember(); // is this symbol a member of an AggregateDeclaration? | |
193 virtual Type *getType(); // is this a type? | |
194 virtual char *mangle(); | |
195 virtual int needThis(); // need a 'this' pointer? | |
196 virtual enum PROT prot(); | |
197 virtual Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees | |
198 virtual int oneMember(Dsymbol **ps); | |
199 static int oneMembers(Array *members, Dsymbol **ps); | |
200 virtual int hasPointers(); | |
201 virtual void addLocalClass(ClassDeclarations *) { } | |
202 virtual void checkCtorConstInit() { } | |
203 | |
204 virtual void addComment(unsigned char *comment); | |
205 virtual void emitComment(Scope *sc); | |
206 void emitDitto(Scope *sc); | |
207 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
208 #if IN_DMD |
159 | 209 // Backend |
210 | |
211 virtual Symbol *toSymbol(); // to backend symbol | |
336 | 212 virtual void toObjFile(int multiobj); // compile to .obj file |
159 | 213 virtual int cvMember(unsigned char *p); // emit cv debug info for member |
214 | |
215 Symbol *toImport(); // to backend import symbol | |
216 static Symbol *toImport(Symbol *s); // to backend import symbol | |
217 | |
218 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
|
219 #endif |
159 | 220 |
221 // Eliminate need for dynamic_cast | |
222 virtual Package *isPackage() { return NULL; } | |
223 virtual Module *isModule() { return NULL; } | |
224 virtual EnumMember *isEnumMember() { return NULL; } | |
225 virtual TemplateDeclaration *isTemplateDeclaration() { return NULL; } | |
226 virtual TemplateInstance *isTemplateInstance() { return NULL; } | |
227 virtual TemplateMixin *isTemplateMixin() { return NULL; } | |
228 virtual Declaration *isDeclaration() { return NULL; } | |
1587 | 229 virtual ThisDeclaration *isThisDeclaration() { return NULL; } |
159 | 230 virtual TupleDeclaration *isTupleDeclaration() { return NULL; } |
231 virtual TypedefDeclaration *isTypedefDeclaration() { return NULL; } | |
232 virtual AliasDeclaration *isAliasDeclaration() { return NULL; } | |
233 virtual AggregateDeclaration *isAggregateDeclaration() { return NULL; } | |
234 virtual FuncDeclaration *isFuncDeclaration() { return NULL; } | |
235 virtual FuncAliasDeclaration *isFuncAliasDeclaration() { return NULL; } | |
236 virtual FuncLiteralDeclaration *isFuncLiteralDeclaration() { return NULL; } | |
237 virtual CtorDeclaration *isCtorDeclaration() { return NULL; } | |
1587 | 238 virtual PostBlitDeclaration *isPostBlitDeclaration() { return NULL; } |
159 | 239 virtual DtorDeclaration *isDtorDeclaration() { return NULL; } |
240 virtual StaticCtorDeclaration *isStaticCtorDeclaration() { return NULL; } | |
241 virtual StaticDtorDeclaration *isStaticDtorDeclaration() { return NULL; } | |
242 virtual InvariantDeclaration *isInvariantDeclaration() { return NULL; } | |
243 virtual UnitTestDeclaration *isUnitTestDeclaration() { return NULL; } | |
244 virtual NewDeclaration *isNewDeclaration() { return NULL; } | |
245 virtual VarDeclaration *isVarDeclaration() { return NULL; } | |
246 virtual ClassDeclaration *isClassDeclaration() { return NULL; } | |
247 virtual StructDeclaration *isStructDeclaration() { return NULL; } | |
248 virtual UnionDeclaration *isUnionDeclaration() { return NULL; } | |
249 virtual InterfaceDeclaration *isInterfaceDeclaration() { return NULL; } | |
250 virtual ScopeDsymbol *isScopeDsymbol() { return NULL; } | |
251 virtual WithScopeSymbol *isWithScopeSymbol() { return NULL; } | |
252 virtual ArrayScopeSymbol *isArrayScopeSymbol() { return NULL; } | |
253 virtual Import *isImport() { return NULL; } | |
254 virtual EnumDeclaration *isEnumDeclaration() { return NULL; } | |
255 #ifdef _DH | |
256 virtual DeleteDeclaration *isDeleteDeclaration() { return NULL; } | |
257 #endif | |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
258 virtual StaticStructInitDeclaration *isStaticStructInitDeclaration() { return NULL; } |
159 | 259 virtual AttribDeclaration *isAttribDeclaration() { return NULL; } |
260 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return NULL; } | |
261 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
|
262 |
1587 | 263 virtual OverloadSet *isOverloadSet() { return NULL; } |
264 #if TARGET_NET | |
265 virtual PragmaScope* isPragmaScope() { return NULL; } | |
266 #endif | |
267 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
946
diff
changeset
|
268 #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
|
269 /// Codegen traversal |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
270 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
|
271 |
159 | 272 // llvm stuff |
273 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
|
274 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
159
diff
changeset
|
275 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
|
276 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
|
277 #endif |
159 | 278 }; |
279 | |
280 // Dsymbol that generates a scope | |
281 | |
282 struct ScopeDsymbol : Dsymbol | |
283 { | |
284 Array *members; // all Dsymbol's in this scope | |
285 DsymbolTable *symtab; // members[] sorted into table | |
286 | |
287 Array *imports; // imported ScopeDsymbol's | |
1587 | 288 unsigned char *prots; // array of PROT, one for each import |
159 | 289 |
290 ScopeDsymbol(); | |
291 ScopeDsymbol(Identifier *id); | |
292 Dsymbol *syntaxCopy(Dsymbol *s); | |
293 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
294 void importScope(ScopeDsymbol *s, enum PROT protection); | |
295 int isforwardRef(); | |
296 void defineRef(Dsymbol *s); | |
297 static void multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2); | |
298 Dsymbol *nameCollision(Dsymbol *s); | |
336 | 299 const char *kind(); |
1587 | 300 FuncDeclaration *findGetMembers(); |
301 virtual Dsymbol *symtabInsert(Dsymbol *s); | |
159 | 302 |
303 void emitMemberComments(Scope *sc); | |
304 | |
1587 | 305 static size_t dim(Array *members); |
306 static Dsymbol *getNth(Array *members, size_t nth, size_t *pn = NULL); | |
307 | |
159 | 308 ScopeDsymbol *isScopeDsymbol() { return this; } |
309 }; | |
310 | |
311 // With statement scope | |
312 | |
313 struct WithScopeSymbol : ScopeDsymbol | |
314 { | |
315 WithStatement *withstate; | |
316 | |
317 WithScopeSymbol(WithStatement *withstate); | |
318 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
319 | |
320 WithScopeSymbol *isWithScopeSymbol() { return this; } | |
321 }; | |
322 | |
323 // Array Index/Slice scope | |
324 | |
325 struct ArrayScopeSymbol : ScopeDsymbol | |
326 { | |
327 Expression *exp; // IndexExp or SliceExp | |
328 TypeTuple *type; // for tuple[length] | |
329 TupleDeclaration *td; // for tuples of objects | |
1587 | 330 Scope *sc; |
159 | 331 |
332 ArrayScopeSymbol(Expression *e); | |
333 ArrayScopeSymbol(TypeTuple *t); | |
334 ArrayScopeSymbol(TupleDeclaration *td); | |
335 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
336 | |
337 ArrayScopeSymbol *isArrayScopeSymbol() { return this; } | |
338 }; | |
339 | |
1587 | 340 // Overload Sets |
341 | |
342 #if DMDV2 | |
343 struct OverloadSet : Dsymbol | |
344 { | |
345 Dsymbols a; // array of Dsymbols | |
346 | |
347 OverloadSet(); | |
348 void push(Dsymbol *s); | |
349 OverloadSet *isOverloadSet() { return this; } | |
350 const char *kind(); | |
351 }; | |
352 #endif | |
353 | |
159 | 354 // Table of Dsymbol's |
355 | |
356 struct DsymbolTable : Object | |
357 { | |
358 StringTable *tab; | |
359 | |
360 DsymbolTable(); | |
361 ~DsymbolTable(); | |
362 | |
363 // Look up Identifier. Return Dsymbol if found, NULL if not. | |
364 Dsymbol *lookup(Identifier *ident); | |
365 | |
366 // Insert Dsymbol in table. Return NULL if already there. | |
367 Dsymbol *insert(Dsymbol *s); | |
368 | |
369 // Look for Dsymbol in table. If there, return it. If not, insert s and return that. | |
370 Dsymbol *update(Dsymbol *s); | |
371 Dsymbol *insert(Identifier *ident, Dsymbol *s); // when ident and s are not the same | |
372 }; | |
373 | |
374 #endif /* DMD_DSYMBOL_H */ |