Mercurial > projects > ldc
annotate dmd/declaration.h @ 305:2b72433d5c8c trunk
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
Fixed problems with label collisions when using labels inside inline asm. LabelStatement is now easily reached given its
Identifier, which should be useful elsewhere too.
Enabled inline asm for building the lib/compiler/llvmdc runtime code, fixing branches out of asm makes this possible.
author | lindquist |
---|---|
date | Fri, 27 Jun 2008 22:04:35 +0200 |
parents | 5acec6b2eef8 |
children | aaade6ded589 |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2008 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_DECLARATION_H | |
12 #define DMD_DECLARATION_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include <set> | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
19 #include <map> |
159 | 20 |
21 #include "dsymbol.h" | |
22 #include "lexer.h" | |
23 #include "mtype.h" | |
24 | |
25 struct Expression; | |
26 struct Statement; | |
27 struct LabelDsymbol; | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
28 struct LabelStatement; |
159 | 29 struct Initializer; |
30 struct Module; | |
31 struct InlineScanState; | |
32 struct ForeachStatement; | |
33 struct FuncDeclaration; | |
34 struct ExpInitializer; | |
35 struct StructDeclaration; | |
36 struct TupleType; | |
37 struct InterState; | |
38 struct IRState; | |
39 | |
40 enum PROT; | |
41 enum LINK; | |
42 enum TOK; | |
43 enum MATCH; | |
44 | |
45 enum STC | |
46 { | |
47 STCundefined = 0, | |
48 STCstatic = 1, | |
49 STCextern = 2, | |
50 STCconst = 4, | |
51 STCfinal = 8, | |
52 STCabstract = 0x10, | |
53 STCparameter = 0x20, | |
54 STCfield = 0x40, | |
55 STCoverride = 0x80, | |
56 STCauto = 0x100, | |
57 STCsynchronized = 0x200, | |
58 STCdeprecated = 0x400, | |
59 STCin = 0x800, // in parameter | |
60 STCout = 0x1000, // out parameter | |
61 STClazy = 0x2000, // lazy parameter | |
62 STCforeach = 0x4000, // variable for foreach loop | |
63 STCcomdat = 0x8000, // should go into COMDAT record | |
64 STCvariadic = 0x10000, // variadic function argument | |
65 STCctorinit = 0x20000, // can only be set inside constructor | |
66 STCtemplateparameter = 0x40000, // template parameter | |
67 STCscope = 0x80000, // template parameter | |
68 STCinvariant = 0x100000, | |
69 STCref = 0x200000, | |
70 STCinit = 0x400000, // has explicit initializer | |
71 STCmanifest = 0x800000, // manifest constant | |
72 STCnodtor = 0x1000000, // don't run destructor | |
73 STCnothrow = 0x2000000, // never throws exceptions | |
74 STCpure = 0x4000000, // pure function | |
75 STCtls = 0x8000000, // thread local | |
76 }; | |
77 | |
78 struct Match | |
79 { | |
80 int count; // number of matches found | |
81 MATCH last; // match level of lastf | |
82 FuncDeclaration *lastf; // last matching function we found | |
83 FuncDeclaration *nextf; // current matching function | |
84 FuncDeclaration *anyf; // pick a func, any func, to use for error recovery | |
85 }; | |
86 | |
87 void overloadResolveX(Match *m, FuncDeclaration *f, Expressions *arguments); | |
88 int overloadApply(FuncDeclaration *fstart, | |
89 int (*fp)(void *, FuncDeclaration *), | |
90 void *param); | |
91 | |
92 /**************************************************************/ | |
93 | |
94 struct Declaration : Dsymbol | |
95 { | |
96 Type *type; | |
97 Type *originalType; // before semantic analysis | |
98 unsigned storage_class; | |
99 enum PROT protection; | |
100 enum LINK linkage; | |
101 | |
102 Declaration(Identifier *id); | |
103 void semantic(Scope *sc); | |
104 char *kind(); | |
105 unsigned size(Loc loc); | |
106 void checkModify(Loc loc, Scope *sc, Type *t); | |
107 | |
108 void emitComment(Scope *sc); | |
109 void toDocBuffer(OutBuffer *buf); | |
110 | |
111 char *mangle(); | |
112 int isStatic() { return storage_class & STCstatic; } | |
113 virtual int isStaticConstructor(); | |
114 virtual int isStaticDestructor(); | |
115 virtual int isDelete(); | |
116 virtual int isDataseg(); | |
117 virtual int isCodeseg(); | |
118 int isCtorinit() { return storage_class & STCctorinit; } | |
119 int isFinal() { return storage_class & STCfinal; } | |
120 int isAbstract() { return storage_class & STCabstract; } | |
121 int isConst() { return storage_class & STCconst; } | |
122 int isInvariant() { return 0; } | |
123 int isAuto() { return storage_class & STCauto; } | |
124 int isScope() { return storage_class & (STCscope | STCauto); } | |
125 int isSynchronized() { return storage_class & STCsynchronized; } | |
126 int isParameter() { return storage_class & STCparameter; } | |
127 int isDeprecated() { return storage_class & STCdeprecated; } | |
128 int isOverride() { return storage_class & STCoverride; } | |
129 | |
130 int isIn() { return storage_class & STCin; } | |
131 int isOut() { return storage_class & STCout; } | |
132 int isRef() { return storage_class & STCref; } | |
133 | |
134 enum PROT prot(); | |
135 | |
136 Declaration *isDeclaration() { return this; } | |
137 | |
138 // llvm | |
139 virtual void toObjFile(); // compile to .obj file | |
140 }; | |
141 | |
142 /**************************************************************/ | |
143 | |
144 struct TupleDeclaration : Declaration | |
145 { | |
146 Objects *objects; | |
147 int isexp; // 1: expression tuple | |
148 | |
149 TypeTuple *tupletype; // !=NULL if this is a type tuple | |
150 | |
151 TupleDeclaration(Loc loc, Identifier *ident, Objects *objects); | |
152 Dsymbol *syntaxCopy(Dsymbol *); | |
153 char *kind(); | |
154 Type *getType(); | |
155 int needThis(); | |
156 | |
157 TupleDeclaration *isTupleDeclaration() { return this; } | |
158 }; | |
159 | |
160 /**************************************************************/ | |
161 | |
162 struct TypedefDeclaration : Declaration | |
163 { | |
164 Type *basetype; | |
165 Initializer *init; | |
166 int sem; // 0: semantic() has not been run | |
167 // 1: semantic() is in progress | |
168 // 2: semantic() has been run | |
169 // 3: semantic2() has been run | |
170 int inuse; // used to detect typedef cycles | |
171 | |
172 TypedefDeclaration(Loc loc, Identifier *ident, Type *basetype, Initializer *init); | |
173 Dsymbol *syntaxCopy(Dsymbol *); | |
174 void semantic(Scope *sc); | |
175 void semantic2(Scope *sc); | |
176 char *mangle(); | |
177 char *kind(); | |
178 Type *getType(); | |
179 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
180 #ifdef _DH | |
181 Type *htype; | |
182 Type *hbasetype; | |
183 #endif | |
184 | |
185 void toDocBuffer(OutBuffer *buf); | |
186 | |
187 void toObjFile(); // compile to .obj file | |
188 void toDebug(); | |
189 int cvMember(unsigned char *p); | |
190 | |
191 TypedefDeclaration *isTypedefDeclaration() { return this; } | |
192 | |
193 Symbol *sinit; | |
194 Symbol *toInitializer(); | |
195 }; | |
196 | |
197 /**************************************************************/ | |
198 | |
199 struct AliasDeclaration : Declaration | |
200 { | |
201 Dsymbol *aliassym; | |
202 Dsymbol *overnext; // next in overload list | |
203 int inSemantic; | |
204 | |
205 AliasDeclaration(Loc loc, Identifier *ident, Type *type); | |
206 AliasDeclaration(Loc loc, Identifier *ident, Dsymbol *s); | |
207 Dsymbol *syntaxCopy(Dsymbol *); | |
208 void semantic(Scope *sc); | |
209 int overloadInsert(Dsymbol *s); | |
210 char *kind(); | |
211 Type *getType(); | |
212 Dsymbol *toAlias(); | |
213 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
214 #ifdef _DH | |
215 Type *htype; | |
216 Dsymbol *haliassym; | |
217 #endif | |
218 | |
219 void toDocBuffer(OutBuffer *buf); | |
220 | |
221 AliasDeclaration *isAliasDeclaration() { return this; } | |
222 }; | |
223 | |
224 /**************************************************************/ | |
225 | |
226 struct VarDeclaration : Declaration | |
227 { | |
228 Initializer *init; | |
229 unsigned offset; | |
230 int noauto; // no auto semantics | |
231 int nestedref; // referenced by a lexically nested function | |
232 int inuse; | |
233 int ctorinit; // it has been initialized in a ctor | |
234 int onstack; // 1: it has been allocated on the stack | |
235 // 2: on stack, run destructor anyway | |
236 int canassign; // it can be assigned to | |
237 Dsymbol *aliassym; // if redone as alias to another symbol | |
238 Expression *value; // when interpreting, this is the value | |
239 // (NULL if value not determinable) | |
240 | |
241 VarDeclaration(Loc loc, Type *t, Identifier *id, Initializer *init); | |
242 Dsymbol *syntaxCopy(Dsymbol *); | |
243 void semantic(Scope *sc); | |
244 void semantic2(Scope *sc); | |
245 char *kind(); | |
246 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
247 #ifdef _DH | |
248 Type *htype; | |
249 Initializer *hinit; | |
250 #endif | |
251 int needThis(); | |
252 int isImportedSymbol(); | |
253 int isDataseg(); | |
254 int hasPointers(); | |
255 Expression *callAutoDtor(); | |
256 ExpInitializer *getExpInitializer(); | |
257 void checkCtorConstInit(); | |
258 void checkNestedReference(Scope *sc, Loc loc); | |
259 Dsymbol *toAlias(); | |
260 | |
261 Symbol *toSymbol(); | |
262 void toObjFile(); // compile to .obj file | |
263 int cvMember(unsigned char *p); | |
264 | |
265 // Eliminate need for dynamic_cast | |
266 VarDeclaration *isVarDeclaration() { return (VarDeclaration *)this; } | |
267 | |
268 // LLVMDC | |
269 bool needsStorage; | |
270 }; | |
271 | |
272 /**************************************************************/ | |
273 | |
274 // This is a shell around a back end symbol | |
275 | |
276 struct SymbolDeclaration : Declaration | |
277 { | |
278 Symbol *sym; | |
279 StructDeclaration *dsym; | |
280 | |
281 SymbolDeclaration(Loc loc, Symbol *s, StructDeclaration *dsym); | |
282 | |
283 Symbol *toSymbol(); | |
284 | |
285 // Eliminate need for dynamic_cast | |
286 SymbolDeclaration *isSymbolDeclaration() { return (SymbolDeclaration *)this; } | |
287 }; | |
288 | |
289 struct ClassInfoDeclaration : VarDeclaration | |
290 { | |
291 ClassDeclaration *cd; | |
292 | |
293 ClassInfoDeclaration(ClassDeclaration *cd); | |
294 Dsymbol *syntaxCopy(Dsymbol *); | |
295 void semantic(Scope *sc); | |
296 | |
297 void emitComment(Scope *sc); | |
298 | |
299 Symbol *toSymbol(); | |
300 | |
301 ClassInfoDeclaration* isClassInfoDeclaration() { return this; } | |
302 }; | |
303 | |
304 struct ModuleInfoDeclaration : VarDeclaration | |
305 { | |
306 Module *mod; | |
307 | |
308 ModuleInfoDeclaration(Module *mod); | |
309 Dsymbol *syntaxCopy(Dsymbol *); | |
310 void semantic(Scope *sc); | |
311 | |
312 void emitComment(Scope *sc); | |
313 | |
314 Symbol *toSymbol(); | |
315 }; | |
316 | |
317 struct TypeInfoDeclaration : VarDeclaration | |
318 { | |
319 Type *tinfo; | |
320 | |
321 TypeInfoDeclaration(Type *tinfo, int internal); | |
322 Dsymbol *syntaxCopy(Dsymbol *); | |
323 void semantic(Scope *sc); | |
324 | |
325 void emitComment(Scope *sc); | |
326 | |
327 Symbol *toSymbol(); | |
328 void toObjFile(); // compile to .obj file | |
329 virtual void toDt(dt_t **pdt); | |
330 | |
331 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return this; } | |
332 | |
333 // LLVMDC | |
334 virtual void llvmDeclare(); | |
335 virtual void llvmDefine(); | |
336 }; | |
337 | |
338 struct TypeInfoStructDeclaration : TypeInfoDeclaration | |
339 { | |
340 TypeInfoStructDeclaration(Type *tinfo); | |
341 | |
342 void toDt(dt_t **pdt); | |
343 | |
344 // LLVMDC | |
345 void llvmDeclare(); | |
346 void llvmDefine(); | |
347 }; | |
348 | |
349 struct TypeInfoClassDeclaration : TypeInfoDeclaration | |
350 { | |
351 TypeInfoClassDeclaration(Type *tinfo); | |
352 | |
353 void toDt(dt_t **pdt); | |
354 | |
355 // LLVMDC | |
356 void llvmDeclare(); | |
357 void llvmDefine(); | |
358 }; | |
359 | |
360 struct TypeInfoInterfaceDeclaration : TypeInfoDeclaration | |
361 { | |
362 TypeInfoInterfaceDeclaration(Type *tinfo); | |
363 | |
364 void toDt(dt_t **pdt); | |
365 | |
366 // LLVMDC | |
367 void llvmDeclare(); | |
368 void llvmDefine(); | |
369 }; | |
370 | |
371 struct TypeInfoTypedefDeclaration : TypeInfoDeclaration | |
372 { | |
373 TypeInfoTypedefDeclaration(Type *tinfo); | |
374 | |
375 void toDt(dt_t **pdt); | |
376 | |
377 // LLVMDC | |
378 void llvmDeclare(); | |
379 void llvmDefine(); | |
380 }; | |
381 | |
382 struct TypeInfoPointerDeclaration : TypeInfoDeclaration | |
383 { | |
384 TypeInfoPointerDeclaration(Type *tinfo); | |
385 | |
386 void toDt(dt_t **pdt); | |
387 | |
388 // LLVMDC | |
389 void llvmDeclare(); | |
390 void llvmDefine(); | |
391 }; | |
392 | |
393 struct TypeInfoArrayDeclaration : TypeInfoDeclaration | |
394 { | |
395 TypeInfoArrayDeclaration(Type *tinfo); | |
396 | |
397 void toDt(dt_t **pdt); | |
398 | |
399 // LLVMDC | |
400 void llvmDeclare(); | |
401 void llvmDefine(); | |
402 }; | |
403 | |
404 struct TypeInfoStaticArrayDeclaration : TypeInfoDeclaration | |
405 { | |
406 TypeInfoStaticArrayDeclaration(Type *tinfo); | |
407 | |
408 void toDt(dt_t **pdt); | |
409 | |
410 // LLVMDC | |
411 void llvmDeclare(); | |
412 void llvmDefine(); | |
413 }; | |
414 | |
415 struct TypeInfoAssociativeArrayDeclaration : TypeInfoDeclaration | |
416 { | |
417 TypeInfoAssociativeArrayDeclaration(Type *tinfo); | |
418 | |
419 void toDt(dt_t **pdt); | |
420 | |
421 // LLVMDC | |
422 void llvmDeclare(); | |
423 void llvmDefine(); | |
424 }; | |
425 | |
426 struct TypeInfoEnumDeclaration : TypeInfoDeclaration | |
427 { | |
428 TypeInfoEnumDeclaration(Type *tinfo); | |
429 | |
430 void toDt(dt_t **pdt); | |
431 | |
432 // LLVMDC | |
433 void llvmDeclare(); | |
434 void llvmDefine(); | |
435 }; | |
436 | |
437 struct TypeInfoFunctionDeclaration : TypeInfoDeclaration | |
438 { | |
439 TypeInfoFunctionDeclaration(Type *tinfo); | |
440 | |
441 void toDt(dt_t **pdt); | |
442 | |
443 // LLVMDC | |
444 void llvmDeclare(); | |
445 void llvmDefine(); | |
446 }; | |
447 | |
448 struct TypeInfoDelegateDeclaration : TypeInfoDeclaration | |
449 { | |
450 TypeInfoDelegateDeclaration(Type *tinfo); | |
451 | |
452 void toDt(dt_t **pdt); | |
453 | |
454 // LLVMDC | |
455 void llvmDeclare(); | |
456 void llvmDefine(); | |
457 }; | |
458 | |
459 struct TypeInfoTupleDeclaration : TypeInfoDeclaration | |
460 { | |
461 TypeInfoTupleDeclaration(Type *tinfo); | |
462 | |
463 void toDt(dt_t **pdt); | |
464 | |
465 // LLVMDC | |
466 void llvmDeclare(); | |
467 void llvmDefine(); | |
468 }; | |
469 | |
470 struct ThisDeclaration : VarDeclaration | |
471 { | |
472 ThisDeclaration(Type *t); | |
473 Dsymbol *syntaxCopy(Dsymbol *); | |
474 }; | |
475 | |
476 enum ILS | |
477 { | |
478 ILSuninitialized, // not computed yet | |
479 ILSno, // cannot inline | |
480 ILSyes, // can inline | |
481 }; | |
482 | |
483 /**************************************************************/ | |
484 | |
485 #if V2 | |
486 | |
487 enum BUILTIN | |
488 { | |
489 BUILTINunknown = -1, // not known if this is a builtin | |
490 BUILTINnot, // this is not a builtin | |
491 BUILTINsin, // std.math.sin | |
492 BUILTINcos, // std.math.cos | |
493 BUILTINtan, // std.math.tan | |
494 BUILTINsqrt, // std.math.sqrt | |
495 BUILTINfabs, // std.math.fabs | |
496 }; | |
497 | |
498 Expression *eval_builtin(enum BUILTIN builtin, Expressions *arguments); | |
499 | |
500 #endif | |
501 | |
502 struct FuncDeclaration : Declaration | |
503 { | |
504 Array *fthrows; // Array of Type's of exceptions (not used) | |
505 Statement *frequire; | |
506 Statement *fensure; | |
507 Statement *fbody; | |
508 | |
509 Identifier *outId; // identifier for out statement | |
510 VarDeclaration *vresult; // variable corresponding to outId | |
511 LabelDsymbol *returnLabel; // where the return goes | |
512 | |
513 DsymbolTable *localsymtab; // used to prevent symbols in different | |
514 // scopes from having the same name | |
515 VarDeclaration *vthis; // 'this' parameter (member and nested) | |
516 VarDeclaration *v_arguments; // '_arguments' parameter | |
517 #if IN_GCC | |
518 VarDeclaration *v_argptr; // '_argptr' variable | |
519 #endif | |
520 Dsymbols *parameters; // Array of VarDeclaration's for parameters | |
521 DsymbolTable *labtab; // statement label symbol table | |
522 Declaration *overnext; // next in overload list | |
523 Loc endloc; // location of closing curly bracket | |
524 int vtblIndex; // for member functions, index into vtbl[] | |
525 int naked; // !=0 if naked | |
526 int inlineAsm; // !=0 if has inline assembler | |
527 ILS inlineStatus; | |
528 int inlineNest; // !=0 if nested inline | |
529 int cantInterpret; // !=0 if cannot interpret function | |
530 int semanticRun; // !=0 if semantic3() had been run | |
531 // this function's frame ptr | |
532 ForeachStatement *fes; // if foreach body, this is the foreach | |
533 int introducing; // !=0 if 'introducing' function | |
534 Type *tintro; // if !=NULL, then this is the type | |
535 // of the 'introducing' function | |
536 // this one is overriding | |
537 int inferRetType; // !=0 if return type is to be inferred | |
538 Scope *scope; // !=NULL means context to use | |
539 | |
540 // Things that should really go into Scope | |
541 int hasReturnExp; // 1 if there's a return exp; statement | |
542 // 2 if there's a throw statement | |
543 // 4 if there's an assert(0) | |
544 // 8 if there's inline asm | |
545 | |
546 // Support for NRVO (named return value optimization) | |
547 int nrvo_can; // !=0 means we can do it | |
548 VarDeclaration *nrvo_var; // variable to replace with shidden | |
549 Symbol *shidden; // hidden pointer passed to function | |
550 | |
551 #if V2 | |
552 enum BUILTIN builtin; // set if this is a known, builtin | |
553 // function we can evaluate at compile | |
554 // time | |
555 | |
556 int tookAddressOf; // set if someone took the address of | |
557 // this function | |
558 Dsymbols closureVars; // local variables in this function | |
559 // which are referenced by nested | |
560 // functions | |
561 #else | |
562 int nestedFrameRef; // !=0 if nested variables referenced | |
563 #endif | |
564 | |
565 FuncDeclaration(Loc loc, Loc endloc, Identifier *id, enum STC storage_class, Type *type); | |
566 Dsymbol *syntaxCopy(Dsymbol *); | |
567 void semantic(Scope *sc); | |
568 void semantic2(Scope *sc); | |
569 void semantic3(Scope *sc); | |
570 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
571 void bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
572 int overrides(FuncDeclaration *fd); | |
573 int findVtblIndex(Array *vtbl, int dim); | |
574 int overloadInsert(Dsymbol *s); | |
575 FuncDeclaration *overloadExactMatch(Type *t); | |
576 FuncDeclaration *overloadResolve(Loc loc, Expressions *arguments); | |
577 LabelDsymbol *searchLabel(Identifier *ident); | |
578 AggregateDeclaration *isThis(); | |
579 AggregateDeclaration *isMember2(); | |
580 int getLevel(Loc loc, FuncDeclaration *fd); // lexical nesting level difference | |
581 void appendExp(Expression *e); | |
582 void appendState(Statement *s); | |
583 char *mangle(); | |
584 int isMain(); | |
585 int isWinMain(); | |
586 int isDllMain(); | |
587 int isExport(); | |
588 int isImportedSymbol(); | |
589 int isAbstract(); | |
590 int isCodeseg(); | |
591 virtual int isNested(); | |
592 int needThis(); | |
593 virtual int isVirtual(); | |
594 virtual int addPreInvariant(); | |
595 virtual int addPostInvariant(); | |
596 Expression *interpret(InterState *istate, Expressions *arguments); | |
597 void inlineScan(); | |
598 int canInline(int hasthis, int hdrscan = 0); | |
599 Expression *doInline(InlineScanState *iss, Expression *ethis, Array *arguments); | |
600 char *kind(); | |
601 void toDocBuffer(OutBuffer *buf); | |
602 | |
603 static FuncDeclaration *genCfunc(Type *treturn, char *name); | |
604 static FuncDeclaration *genCfunc(Type *treturn, Identifier *id); | |
605 | |
606 Symbol *toSymbol(); | |
607 Symbol *toThunkSymbol(int offset); // thunk version | |
608 void toObjFile(); // compile to .obj file | |
609 int cvMember(unsigned char *p); | |
610 | |
611 FuncDeclaration *isFuncDeclaration() { return this; } | |
612 | |
613 // llvmdc stuff | |
614 bool runTimeHack; | |
615 std::set<VarDeclaration*> nestedVars; | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
616 |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
617 // we keep our own table of label statements as LabelDsymbolS |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
618 // don't always carry their corresponding statement along ... |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
619 typedef std::map<const char*, LabelStatement*> LabelMap; |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
620 LabelMap labmap; |
159 | 621 }; |
622 | |
623 struct FuncAliasDeclaration : FuncDeclaration | |
624 { | |
625 FuncDeclaration *funcalias; | |
626 | |
627 FuncAliasDeclaration(FuncDeclaration *funcalias); | |
628 | |
629 FuncAliasDeclaration *isFuncAliasDeclaration() { return this; } | |
630 char *kind(); | |
631 Symbol *toSymbol(); | |
632 }; | |
633 | |
634 struct FuncLiteralDeclaration : FuncDeclaration | |
635 { | |
636 enum TOK tok; // TOKfunction or TOKdelegate | |
637 | |
638 FuncLiteralDeclaration(Loc loc, Loc endloc, Type *type, enum TOK tok, | |
639 ForeachStatement *fes); | |
640 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
641 Dsymbol *syntaxCopy(Dsymbol *); | |
642 int isNested(); | |
643 | |
644 FuncLiteralDeclaration *isFuncLiteralDeclaration() { return this; } | |
645 char *kind(); | |
646 }; | |
647 | |
648 struct CtorDeclaration : FuncDeclaration | |
649 { Arguments *arguments; | |
650 int varargs; | |
651 | |
652 CtorDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); | |
653 Dsymbol *syntaxCopy(Dsymbol *); | |
654 void semantic(Scope *sc); | |
655 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
656 char *kind(); | |
657 char *toChars(); | |
658 int isVirtual(); | |
659 int addPreInvariant(); | |
660 int addPostInvariant(); | |
661 void toDocBuffer(OutBuffer *buf); | |
662 | |
663 CtorDeclaration *isCtorDeclaration() { return this; } | |
664 }; | |
665 | |
666 struct DtorDeclaration : FuncDeclaration | |
667 { | |
668 DtorDeclaration(Loc loc, Loc endloc); | |
669 DtorDeclaration(Loc loc, Loc endloc, Identifier *id); | |
670 Dsymbol *syntaxCopy(Dsymbol *); | |
671 void semantic(Scope *sc); | |
672 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
673 int isVirtual(); | |
674 int addPreInvariant(); | |
675 int addPostInvariant(); | |
676 int overloadInsert(Dsymbol *s); | |
677 void emitComment(Scope *sc); | |
678 | |
679 DtorDeclaration *isDtorDeclaration() { return this; } | |
680 }; | |
681 | |
682 struct StaticCtorDeclaration : FuncDeclaration | |
683 { | |
684 StaticCtorDeclaration(Loc loc, Loc endloc); | |
685 Dsymbol *syntaxCopy(Dsymbol *); | |
686 void semantic(Scope *sc); | |
687 AggregateDeclaration *isThis(); | |
688 int isStaticConstructor(); | |
689 int isVirtual(); | |
690 int addPreInvariant(); | |
691 int addPostInvariant(); | |
692 void emitComment(Scope *sc); | |
693 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
694 | |
695 StaticCtorDeclaration *isStaticCtorDeclaration() { return this; } | |
696 }; | |
697 | |
698 struct StaticDtorDeclaration : FuncDeclaration | |
699 { | |
700 StaticDtorDeclaration(Loc loc, Loc endloc); | |
701 Dsymbol *syntaxCopy(Dsymbol *); | |
702 void semantic(Scope *sc); | |
703 AggregateDeclaration *isThis(); | |
704 int isStaticDestructor(); | |
705 int isVirtual(); | |
706 int addPreInvariant(); | |
707 int addPostInvariant(); | |
708 void emitComment(Scope *sc); | |
709 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
710 | |
711 StaticDtorDeclaration *isStaticDtorDeclaration() { return this; } | |
712 }; | |
713 | |
714 struct InvariantDeclaration : FuncDeclaration | |
715 { | |
716 InvariantDeclaration(Loc loc, Loc endloc); | |
717 Dsymbol *syntaxCopy(Dsymbol *); | |
718 void semantic(Scope *sc); | |
719 int isVirtual(); | |
720 int addPreInvariant(); | |
721 int addPostInvariant(); | |
722 void emitComment(Scope *sc); | |
723 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
724 | |
725 InvariantDeclaration *isInvariantDeclaration() { return this; } | |
726 }; | |
727 | |
728 | |
729 struct UnitTestDeclaration : FuncDeclaration | |
730 { | |
731 UnitTestDeclaration(Loc loc, Loc endloc); | |
732 Dsymbol *syntaxCopy(Dsymbol *); | |
733 void semantic(Scope *sc); | |
734 AggregateDeclaration *isThis(); | |
735 int isVirtual(); | |
736 int addPreInvariant(); | |
737 int addPostInvariant(); | |
738 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
739 | |
740 UnitTestDeclaration *isUnitTestDeclaration() { return this; } | |
741 }; | |
742 | |
743 struct NewDeclaration : FuncDeclaration | |
744 { Arguments *arguments; | |
745 int varargs; | |
746 | |
747 NewDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); | |
748 Dsymbol *syntaxCopy(Dsymbol *); | |
749 void semantic(Scope *sc); | |
750 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
751 char *kind(); | |
752 int isVirtual(); | |
753 int addPreInvariant(); | |
754 int addPostInvariant(); | |
755 | |
756 NewDeclaration *isNewDeclaration() { return this; } | |
757 }; | |
758 | |
759 | |
760 struct DeleteDeclaration : FuncDeclaration | |
761 { Arguments *arguments; | |
762 | |
763 DeleteDeclaration(Loc loc, Loc endloc, Arguments *arguments); | |
764 Dsymbol *syntaxCopy(Dsymbol *); | |
765 void semantic(Scope *sc); | |
766 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
767 char *kind(); | |
768 int isDelete(); | |
769 int isVirtual(); | |
770 int addPreInvariant(); | |
771 int addPostInvariant(); | |
772 #ifdef _DH | |
773 DeleteDeclaration *isDeleteDeclaration() { return this; } | |
774 #endif | |
775 }; | |
776 | |
777 #endif /* DMD_DECLARATION_H */ |