comparison dmd/dsymbol.h @ 1587:def7a1d494fd

Merge DMD 1.051
author Christian Kamm <kamm incasoftware de>
date Fri, 06 Nov 2009 23:58:01 +0100
parents 229e02867307
children 44b145be2ef5
comparison
equal deleted inserted replaced
1586:7f728c52e63c 1587:def7a1d494fd
1 1
2 // Compiler implementation of the D programming language 2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2008 by Digital Mars 3 // Copyright (c) 1999-2009 by Digital Mars
4 // All Rights Reserved 4 // All Rights Reserved
5 // written by Walter Bright 5 // written by Walter Bright
6 // http://www.digitalmars.com 6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License 7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt. 8 // in artistic.txt, or the GNU General Public License in gnu.txt.
26 26
27 struct Identifier; 27 struct Identifier;
28 struct Scope; 28 struct Scope;
29 struct DsymbolTable; 29 struct DsymbolTable;
30 struct Declaration; 30 struct Declaration;
31 struct ThisDeclaration;
31 struct TupleDeclaration; 32 struct TupleDeclaration;
32 struct TypedefDeclaration; 33 struct TypedefDeclaration;
33 struct AliasDeclaration; 34 struct AliasDeclaration;
34 struct AggregateDeclaration; 35 struct AggregateDeclaration;
35 struct EnumDeclaration; 36 struct EnumDeclaration;
39 struct UnionDeclaration; 40 struct UnionDeclaration;
40 struct FuncDeclaration; 41 struct FuncDeclaration;
41 struct FuncAliasDeclaration; 42 struct FuncAliasDeclaration;
42 struct FuncLiteralDeclaration; 43 struct FuncLiteralDeclaration;
43 struct CtorDeclaration; 44 struct CtorDeclaration;
45 struct PostBlitDeclaration;
44 struct DtorDeclaration; 46 struct DtorDeclaration;
45 struct StaticCtorDeclaration; 47 struct StaticCtorDeclaration;
46 struct StaticDtorDeclaration; 48 struct StaticDtorDeclaration;
47 struct InvariantDeclaration; 49 struct InvariantDeclaration;
48 struct UnitTestDeclaration; 50 struct UnitTestDeclaration;
68 struct Expression; 70 struct Expression;
69 struct DeleteDeclaration; 71 struct DeleteDeclaration;
70 struct HdrGenState; 72 struct HdrGenState;
71 struct TypeInfoDeclaration; 73 struct TypeInfoDeclaration;
72 struct ClassInfoDeclaration; 74 struct ClassInfoDeclaration;
73 75 struct OverloadSet;
76 #if TARGET_NET
77 struct PragmaScope;
78 #endif
74 #if IN_DMD 79 #if IN_DMD
75 struct Symbol; 80 struct Symbol;
76 #endif 81 #endif
77
78 #if IN_GCC 82 #if IN_GCC
79 union tree_node; 83 union tree_node;
80 typedef union tree_node TYPE; 84 typedef union tree_node TYPE;
81 #else 85 #else
82 struct TYPE; 86 struct TYPE;
83 #endif 87 #endif
88
89 // Back end
90 struct Classsym;
84 91
85 #if IN_LLVM 92 #if IN_LLVM
86 class Ir; 93 class Ir;
87 class IrSymbol; 94 class IrSymbol;
88 namespace llvm 95 namespace llvm
112 Symbol *csym; // symbol for code generator 119 Symbol *csym; // symbol for code generator
113 Symbol *isym; // import version of csym 120 Symbol *isym; // import version of csym
114 #endif 121 #endif
115 unsigned char *comment; // documentation comment for this Dsymbol 122 unsigned char *comment; // documentation comment for this Dsymbol
116 Loc loc; // where defined 123 Loc loc; // where defined
124 Scope *scope; // !=NULL means context to use for semantic()
117 125
118 Dsymbol(); 126 Dsymbol();
119 Dsymbol(Identifier *); 127 Dsymbol(Identifier *);
120 char *toChars(); 128 char *toChars();
121 char *toPrettyChars();
122 char *locToChars(); 129 char *locToChars();
123 int equals(Object *o); 130 int equals(Object *o);
124 int isAnonymous(); 131 int isAnonymous();
125 void error(Loc loc, const char *format, ...) IS_PRINTF(3); 132 void error(Loc loc, const char *format, ...) IS_PRINTF(3);
126 void error(const char *format, ...) IS_PRINTF(2); 133 void error(const char *format, ...) IS_PRINTF(2);
134 141
135 int dyncast() { return DYNCAST_DSYMBOL; } // kludge for template.isSymbol() 142 int dyncast() { return DYNCAST_DSYMBOL; } // kludge for template.isSymbol()
136 143
137 static Array *arraySyntaxCopy(Array *a); 144 static Array *arraySyntaxCopy(Array *a);
138 145
146 virtual const char *toPrettyChars();
139 virtual const char *kind(); 147 virtual const char *kind();
140 virtual Dsymbol *toAlias(); // resolve real symbol 148 virtual Dsymbol *toAlias(); // resolve real symbol
141 virtual int addMember(Scope *sc, ScopeDsymbol *s, int memnum); 149 virtual int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
150 virtual void setScope(Scope *sc);
151 virtual void importAll(Scope *sc);
142 virtual void semantic(Scope *sc); 152 virtual void semantic(Scope *sc);
143 virtual void semantic2(Scope *sc); 153 virtual void semantic2(Scope *sc);
144 virtual void semantic3(Scope *sc); 154 virtual void semantic3(Scope *sc);
145 virtual void inlineScan(); 155 virtual void inlineScan();
146 virtual Dsymbol *search(Loc loc, Identifier *ident, int flags); 156 virtual Dsymbol *search(Loc loc, Identifier *ident, int flags);
150 char *toHChars(); 160 char *toHChars();
151 virtual void toHBuffer(OutBuffer *buf, HdrGenState *hgs); 161 virtual void toHBuffer(OutBuffer *buf, HdrGenState *hgs);
152 #endif 162 #endif
153 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 163 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
154 virtual void toDocBuffer(OutBuffer *buf); 164 virtual void toDocBuffer(OutBuffer *buf);
165 virtual void toJsonBuffer(OutBuffer *buf);
155 virtual unsigned size(Loc loc); 166 virtual unsigned size(Loc loc);
156 virtual int isforwardRef(); 167 virtual int isforwardRef();
157 virtual void defineRef(Dsymbol *s); 168 virtual void defineRef(Dsymbol *s);
158 virtual AggregateDeclaration *isThis(); // is a 'this' required to access the member 169 virtual AggregateDeclaration *isThis(); // is a 'this' required to access the member
159 virtual ClassDeclaration *isClassMember(); // are we a member of a class? 170 virtual ClassDeclaration *isClassMember(); // are we a member of a class?
160 virtual int isExport(); // is Dsymbol exported? 171 virtual int isExport(); // is Dsymbol exported?
161 virtual int isImportedSymbol(); // is Dsymbol imported? 172 virtual int isImportedSymbol(); // is Dsymbol imported?
162 virtual int isDeprecated(); // is Dsymbol deprecated? 173 virtual int isDeprecated(); // is Dsymbol deprecated?
174 #if DMDV2
175 virtual int isOverloadable();
176 #endif
163 virtual LabelDsymbol *isLabel(); // is this a LabelDsymbol? 177 virtual LabelDsymbol *isLabel(); // is this a LabelDsymbol?
164 virtual AggregateDeclaration *isMember(); // is this symbol a member of an AggregateDeclaration? 178 virtual AggregateDeclaration *isMember(); // is this symbol a member of an AggregateDeclaration?
165 virtual Type *getType(); // is this a type? 179 virtual Type *getType(); // is this a type?
166 virtual char *mangle(); 180 virtual char *mangle();
167 virtual int needThis(); // need a 'this' pointer? 181 virtual int needThis(); // need a 'this' pointer?
196 virtual EnumMember *isEnumMember() { return NULL; } 210 virtual EnumMember *isEnumMember() { return NULL; }
197 virtual TemplateDeclaration *isTemplateDeclaration() { return NULL; } 211 virtual TemplateDeclaration *isTemplateDeclaration() { return NULL; }
198 virtual TemplateInstance *isTemplateInstance() { return NULL; } 212 virtual TemplateInstance *isTemplateInstance() { return NULL; }
199 virtual TemplateMixin *isTemplateMixin() { return NULL; } 213 virtual TemplateMixin *isTemplateMixin() { return NULL; }
200 virtual Declaration *isDeclaration() { return NULL; } 214 virtual Declaration *isDeclaration() { return NULL; }
215 virtual ThisDeclaration *isThisDeclaration() { return NULL; }
201 virtual TupleDeclaration *isTupleDeclaration() { return NULL; } 216 virtual TupleDeclaration *isTupleDeclaration() { return NULL; }
202 virtual TypedefDeclaration *isTypedefDeclaration() { return NULL; } 217 virtual TypedefDeclaration *isTypedefDeclaration() { return NULL; }
203 virtual AliasDeclaration *isAliasDeclaration() { return NULL; } 218 virtual AliasDeclaration *isAliasDeclaration() { return NULL; }
204 virtual AggregateDeclaration *isAggregateDeclaration() { return NULL; } 219 virtual AggregateDeclaration *isAggregateDeclaration() { return NULL; }
205 virtual FuncDeclaration *isFuncDeclaration() { return NULL; } 220 virtual FuncDeclaration *isFuncDeclaration() { return NULL; }
206 virtual FuncAliasDeclaration *isFuncAliasDeclaration() { return NULL; } 221 virtual FuncAliasDeclaration *isFuncAliasDeclaration() { return NULL; }
207 virtual FuncLiteralDeclaration *isFuncLiteralDeclaration() { return NULL; } 222 virtual FuncLiteralDeclaration *isFuncLiteralDeclaration() { return NULL; }
208 virtual CtorDeclaration *isCtorDeclaration() { return NULL; } 223 virtual CtorDeclaration *isCtorDeclaration() { return NULL; }
224 virtual PostBlitDeclaration *isPostBlitDeclaration() { return NULL; }
209 virtual DtorDeclaration *isDtorDeclaration() { return NULL; } 225 virtual DtorDeclaration *isDtorDeclaration() { return NULL; }
210 virtual StaticCtorDeclaration *isStaticCtorDeclaration() { return NULL; } 226 virtual StaticCtorDeclaration *isStaticCtorDeclaration() { return NULL; }
211 virtual StaticDtorDeclaration *isStaticDtorDeclaration() { return NULL; } 227 virtual StaticDtorDeclaration *isStaticDtorDeclaration() { return NULL; }
212 virtual InvariantDeclaration *isInvariantDeclaration() { return NULL; } 228 virtual InvariantDeclaration *isInvariantDeclaration() { return NULL; }
213 virtual UnitTestDeclaration *isUnitTestDeclaration() { return NULL; } 229 virtual UnitTestDeclaration *isUnitTestDeclaration() { return NULL; }
228 virtual StaticStructInitDeclaration *isStaticStructInitDeclaration() { return NULL; } 244 virtual StaticStructInitDeclaration *isStaticStructInitDeclaration() { return NULL; }
229 virtual AttribDeclaration *isAttribDeclaration() { return NULL; } 245 virtual AttribDeclaration *isAttribDeclaration() { return NULL; }
230 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return NULL; } 246 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return NULL; }
231 virtual ClassInfoDeclaration* isClassInfoDeclaration() { return NULL; } 247 virtual ClassInfoDeclaration* isClassInfoDeclaration() { return NULL; }
232 248
249 virtual OverloadSet *isOverloadSet() { return NULL; }
250 #if TARGET_NET
251 virtual PragmaScope* isPragmaScope() { return NULL; }
252 #endif
253
233 #if IN_LLVM 254 #if IN_LLVM
234 /// Codegen traversal 255 /// Codegen traversal
235 virtual void codegen(Ir* ir); 256 virtual void codegen(Ir* ir);
236 257
237 // llvm stuff 258 // llvm stuff
248 { 269 {
249 Array *members; // all Dsymbol's in this scope 270 Array *members; // all Dsymbol's in this scope
250 DsymbolTable *symtab; // members[] sorted into table 271 DsymbolTable *symtab; // members[] sorted into table
251 272
252 Array *imports; // imported ScopeDsymbol's 273 Array *imports; // imported ScopeDsymbol's
253 unsigned char *prots; // PROT for each import 274 unsigned char *prots; // array of PROT, one for each import
254 275
255 ScopeDsymbol(); 276 ScopeDsymbol();
256 ScopeDsymbol(Identifier *id); 277 ScopeDsymbol(Identifier *id);
257 Dsymbol *syntaxCopy(Dsymbol *s); 278 Dsymbol *syntaxCopy(Dsymbol *s);
258 Dsymbol *search(Loc loc, Identifier *ident, int flags); 279 Dsymbol *search(Loc loc, Identifier *ident, int flags);
260 int isforwardRef(); 281 int isforwardRef();
261 void defineRef(Dsymbol *s); 282 void defineRef(Dsymbol *s);
262 static void multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2); 283 static void multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2);
263 Dsymbol *nameCollision(Dsymbol *s); 284 Dsymbol *nameCollision(Dsymbol *s);
264 const char *kind(); 285 const char *kind();
286 FuncDeclaration *findGetMembers();
287 virtual Dsymbol *symtabInsert(Dsymbol *s);
265 288
266 void emitMemberComments(Scope *sc); 289 void emitMemberComments(Scope *sc);
290
291 static size_t dim(Array *members);
292 static Dsymbol *getNth(Array *members, size_t nth, size_t *pn = NULL);
267 293
268 ScopeDsymbol *isScopeDsymbol() { return this; } 294 ScopeDsymbol *isScopeDsymbol() { return this; }
269 }; 295 };
270 296
271 // With statement scope 297 // With statement scope
285 struct ArrayScopeSymbol : ScopeDsymbol 311 struct ArrayScopeSymbol : ScopeDsymbol
286 { 312 {
287 Expression *exp; // IndexExp or SliceExp 313 Expression *exp; // IndexExp or SliceExp
288 TypeTuple *type; // for tuple[length] 314 TypeTuple *type; // for tuple[length]
289 TupleDeclaration *td; // for tuples of objects 315 TupleDeclaration *td; // for tuples of objects
316 Scope *sc;
290 317
291 ArrayScopeSymbol(Expression *e); 318 ArrayScopeSymbol(Expression *e);
292 ArrayScopeSymbol(TypeTuple *t); 319 ArrayScopeSymbol(TypeTuple *t);
293 ArrayScopeSymbol(TupleDeclaration *td); 320 ArrayScopeSymbol(TupleDeclaration *td);
294 Dsymbol *search(Loc loc, Identifier *ident, int flags); 321 Dsymbol *search(Loc loc, Identifier *ident, int flags);
295 322
296 ArrayScopeSymbol *isArrayScopeSymbol() { return this; } 323 ArrayScopeSymbol *isArrayScopeSymbol() { return this; }
297 }; 324 };
298 325
326 // Overload Sets
327
328 #if DMDV2
329 struct OverloadSet : Dsymbol
330 {
331 Dsymbols a; // array of Dsymbols
332
333 OverloadSet();
334 void push(Dsymbol *s);
335 OverloadSet *isOverloadSet() { return this; }
336 const char *kind();
337 };
338 #endif
339
299 // Table of Dsymbol's 340 // Table of Dsymbol's
300 341
301 struct DsymbolTable : Object 342 struct DsymbolTable : Object
302 { 343 {
303 StringTable *tab; 344 StringTable *tab;