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