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