Mercurial > projects > ldc
annotate dmd/declaration.h @ 715:30b42a283c8e
Removed TypeOpaque from DMD.
Changed runtime functions taking opaque[] to void[].
Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[].
Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86.
Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing.
Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way...
Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8.
Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 14:55:33 +0200 |
parents | 06576ece1a1b |
children | 6aeaef263289 |
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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
332 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
343 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
354 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
365 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
376 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
387 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
398 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
409 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
420 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
431 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
442 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
453 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
464 // LDC |
159 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
476 // LDC |
336 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
487 // LDC |
336 | 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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
627 // LDC: give argument types to runtime functions |
378
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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
638 // LDC stuff |
639
8aebdf56c455
Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
639 |
8aebdf56c455
Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
640 // vars declared in this function that nested funcs reference |
8aebdf56c455
Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
641 // is this is not empty, nestedFrameRef is set and these VarDecls |
8aebdf56c455
Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
642 // probably have nestedref set too, see VarDeclaration::checkNestedReference |
159 | 643 std::set<VarDeclaration*> nestedVars; |
639
8aebdf56c455
Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
644 |
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
|
645 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
|
646 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
647 bool isIntrinsic(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
648 bool isVaIntrinsic(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
649 |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
159
diff
changeset
|
650 // 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
|
651 // 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
|
652 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
|
653 LabelMap labmap; |
703
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
654 |
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
655 // if this is an array operation it gets a little special attention |
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
656 bool isArrayOp; |
159 | 657 }; |
658 | |
659 struct FuncAliasDeclaration : FuncDeclaration | |
660 { | |
661 FuncDeclaration *funcalias; | |
662 | |
663 FuncAliasDeclaration(FuncDeclaration *funcalias); | |
664 | |
665 FuncAliasDeclaration *isFuncAliasDeclaration() { return this; } | |
336 | 666 const char *kind(); |
159 | 667 Symbol *toSymbol(); |
668 }; | |
669 | |
670 struct FuncLiteralDeclaration : FuncDeclaration | |
671 { | |
672 enum TOK tok; // TOKfunction or TOKdelegate | |
673 | |
674 FuncLiteralDeclaration(Loc loc, Loc endloc, Type *type, enum TOK tok, | |
675 ForeachStatement *fes); | |
676 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
677 Dsymbol *syntaxCopy(Dsymbol *); | |
678 int isNested(); | |
336 | 679 int isVirtual(); |
159 | 680 |
681 FuncLiteralDeclaration *isFuncLiteralDeclaration() { return this; } | |
336 | 682 const char *kind(); |
159 | 683 }; |
684 | |
685 struct CtorDeclaration : FuncDeclaration | |
686 { Arguments *arguments; | |
687 int varargs; | |
688 | |
689 CtorDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); | |
690 Dsymbol *syntaxCopy(Dsymbol *); | |
691 void semantic(Scope *sc); | |
692 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
336 | 693 const char *kind(); |
159 | 694 char *toChars(); |
695 int isVirtual(); | |
696 int addPreInvariant(); | |
697 int addPostInvariant(); | |
698 void toDocBuffer(OutBuffer *buf); | |
699 | |
700 CtorDeclaration *isCtorDeclaration() { return this; } | |
701 }; | |
702 | |
336 | 703 #if DMDV2 |
704 struct PostBlitDeclaration : FuncDeclaration | |
705 { | |
706 PostBlitDeclaration(Loc loc, Loc endloc); | |
707 PostBlitDeclaration(Loc loc, Loc endloc, Identifier *id); | |
708 Dsymbol *syntaxCopy(Dsymbol *); | |
709 void semantic(Scope *sc); | |
710 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
711 int isVirtual(); | |
712 int addPreInvariant(); | |
713 int addPostInvariant(); | |
714 int overloadInsert(Dsymbol *s); | |
715 void emitComment(Scope *sc); | |
716 | |
717 PostBlitDeclaration *isPostBlitDeclaration() { return this; } | |
718 }; | |
719 #endif | |
720 | |
159 | 721 struct DtorDeclaration : FuncDeclaration |
722 { | |
723 DtorDeclaration(Loc loc, Loc endloc); | |
724 DtorDeclaration(Loc loc, Loc endloc, Identifier *id); | |
725 Dsymbol *syntaxCopy(Dsymbol *); | |
726 void semantic(Scope *sc); | |
727 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
728 int isVirtual(); | |
729 int addPreInvariant(); | |
730 int addPostInvariant(); | |
731 int overloadInsert(Dsymbol *s); | |
732 void emitComment(Scope *sc); | |
733 | |
734 DtorDeclaration *isDtorDeclaration() { return this; } | |
735 }; | |
736 | |
737 struct StaticCtorDeclaration : FuncDeclaration | |
738 { | |
739 StaticCtorDeclaration(Loc loc, Loc endloc); | |
740 Dsymbol *syntaxCopy(Dsymbol *); | |
741 void semantic(Scope *sc); | |
742 AggregateDeclaration *isThis(); | |
743 int isStaticConstructor(); | |
744 int isVirtual(); | |
745 int addPreInvariant(); | |
746 int addPostInvariant(); | |
747 void emitComment(Scope *sc); | |
748 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
749 | |
750 StaticCtorDeclaration *isStaticCtorDeclaration() { return this; } | |
751 }; | |
752 | |
753 struct StaticDtorDeclaration : FuncDeclaration | |
336 | 754 { VarDeclaration *vgate; // 'gate' variable |
755 | |
159 | 756 StaticDtorDeclaration(Loc loc, Loc endloc); |
757 Dsymbol *syntaxCopy(Dsymbol *); | |
758 void semantic(Scope *sc); | |
759 AggregateDeclaration *isThis(); | |
760 int isStaticDestructor(); | |
761 int isVirtual(); | |
762 int addPreInvariant(); | |
763 int addPostInvariant(); | |
764 void emitComment(Scope *sc); | |
765 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
766 | |
767 StaticDtorDeclaration *isStaticDtorDeclaration() { return this; } | |
768 }; | |
769 | |
770 struct InvariantDeclaration : FuncDeclaration | |
771 { | |
772 InvariantDeclaration(Loc loc, Loc endloc); | |
773 Dsymbol *syntaxCopy(Dsymbol *); | |
774 void semantic(Scope *sc); | |
775 int isVirtual(); | |
776 int addPreInvariant(); | |
777 int addPostInvariant(); | |
778 void emitComment(Scope *sc); | |
779 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
780 | |
781 InvariantDeclaration *isInvariantDeclaration() { return this; } | |
782 }; | |
783 | |
784 | |
785 struct UnitTestDeclaration : FuncDeclaration | |
786 { | |
787 UnitTestDeclaration(Loc loc, Loc endloc); | |
788 Dsymbol *syntaxCopy(Dsymbol *); | |
789 void semantic(Scope *sc); | |
790 AggregateDeclaration *isThis(); | |
791 int isVirtual(); | |
792 int addPreInvariant(); | |
793 int addPostInvariant(); | |
794 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
795 | |
796 UnitTestDeclaration *isUnitTestDeclaration() { return this; } | |
797 }; | |
798 | |
799 struct NewDeclaration : FuncDeclaration | |
800 { Arguments *arguments; | |
801 int varargs; | |
802 | |
803 NewDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); | |
804 Dsymbol *syntaxCopy(Dsymbol *); | |
805 void semantic(Scope *sc); | |
806 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
336 | 807 const char *kind(); |
159 | 808 int isVirtual(); |
809 int addPreInvariant(); | |
810 int addPostInvariant(); | |
811 | |
812 NewDeclaration *isNewDeclaration() { return this; } | |
813 }; | |
814 | |
815 | |
816 struct DeleteDeclaration : FuncDeclaration | |
817 { Arguments *arguments; | |
818 | |
819 DeleteDeclaration(Loc loc, Loc endloc, Arguments *arguments); | |
820 Dsymbol *syntaxCopy(Dsymbol *); | |
821 void semantic(Scope *sc); | |
822 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
336 | 823 const char *kind(); |
159 | 824 int isDelete(); |
825 int isVirtual(); | |
826 int addPreInvariant(); | |
827 int addPostInvariant(); | |
828 #ifdef _DH | |
829 DeleteDeclaration *isDeleteDeclaration() { return this; } | |
830 #endif | |
831 }; | |
832 | |
833 #endif /* DMD_DECLARATION_H */ |