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>
|
|
19
|
|
20 #include "dsymbol.h"
|
|
21 #include "lexer.h"
|
|
22 #include "mtype.h"
|
|
23
|
|
24 struct Expression;
|
|
25 struct Statement;
|
|
26 struct LabelDsymbol;
|
|
27 struct Initializer;
|
|
28 struct Module;
|
|
29 struct InlineScanState;
|
|
30 struct ForeachStatement;
|
|
31 struct FuncDeclaration;
|
|
32 struct ExpInitializer;
|
|
33 struct StructDeclaration;
|
|
34 struct TupleType;
|
|
35 struct InterState;
|
|
36 struct IRState;
|
|
37
|
|
38 enum PROT;
|
|
39 enum LINK;
|
|
40 enum TOK;
|
|
41 enum MATCH;
|
|
42
|
|
43 enum STC
|
|
44 {
|
|
45 STCundefined = 0,
|
|
46 STCstatic = 1,
|
|
47 STCextern = 2,
|
|
48 STCconst = 4,
|
|
49 STCfinal = 8,
|
|
50 STCabstract = 0x10,
|
|
51 STCparameter = 0x20,
|
|
52 STCfield = 0x40,
|
|
53 STCoverride = 0x80,
|
|
54 STCauto = 0x100,
|
|
55 STCsynchronized = 0x200,
|
|
56 STCdeprecated = 0x400,
|
|
57 STCin = 0x800, // in parameter
|
|
58 STCout = 0x1000, // out parameter
|
|
59 STClazy = 0x2000, // lazy parameter
|
|
60 STCforeach = 0x4000, // variable for foreach loop
|
|
61 STCcomdat = 0x8000, // should go into COMDAT record
|
|
62 STCvariadic = 0x10000, // variadic function argument
|
|
63 STCctorinit = 0x20000, // can only be set inside constructor
|
|
64 STCtemplateparameter = 0x40000, // template parameter
|
|
65 STCscope = 0x80000, // template parameter
|
|
66 STCinvariant = 0x100000,
|
|
67 STCref = 0x200000,
|
|
68 STCinit = 0x400000, // has explicit initializer
|
|
69 STCmanifest = 0x800000, // manifest constant
|
|
70 STCnodtor = 0x1000000, // don't run destructor
|
|
71 STCnothrow = 0x2000000, // never throws exceptions
|
|
72 STCpure = 0x4000000, // pure function
|
|
73 STCtls = 0x8000000, // thread local
|
|
74 };
|
|
75
|
|
76 struct Match
|
|
77 {
|
|
78 int count; // number of matches found
|
|
79 MATCH last; // match level of lastf
|
|
80 FuncDeclaration *lastf; // last matching function we found
|
|
81 FuncDeclaration *nextf; // current matching function
|
|
82 FuncDeclaration *anyf; // pick a func, any func, to use for error recovery
|
|
83 };
|
|
84
|
|
85 void overloadResolveX(Match *m, FuncDeclaration *f, Expressions *arguments);
|
|
86 int overloadApply(FuncDeclaration *fstart,
|
|
87 int (*fp)(void *, FuncDeclaration *),
|
|
88 void *param);
|
|
89
|
|
90 /**************************************************************/
|
|
91
|
|
92 struct Declaration : Dsymbol
|
|
93 {
|
|
94 Type *type;
|
|
95 Type *originalType; // before semantic analysis
|
|
96 unsigned storage_class;
|
|
97 enum PROT protection;
|
|
98 enum LINK linkage;
|
|
99
|
|
100 Declaration(Identifier *id);
|
|
101 void semantic(Scope *sc);
|
|
102 char *kind();
|
|
103 unsigned size(Loc loc);
|
|
104 void checkModify(Loc loc, Scope *sc, Type *t);
|
|
105
|
|
106 void emitComment(Scope *sc);
|
|
107 void toDocBuffer(OutBuffer *buf);
|
|
108
|
|
109 char *mangle();
|
|
110 int isStatic() { return storage_class & STCstatic; }
|
|
111 virtual int isStaticConstructor();
|
|
112 virtual int isStaticDestructor();
|
|
113 virtual int isDelete();
|
|
114 virtual int isDataseg();
|
|
115 virtual int isCodeseg();
|
|
116 int isCtorinit() { return storage_class & STCctorinit; }
|
|
117 int isFinal() { return storage_class & STCfinal; }
|
|
118 int isAbstract() { return storage_class & STCabstract; }
|
|
119 int isConst() { return storage_class & STCconst; }
|
|
120 int isInvariant() { return 0; }
|
|
121 int isAuto() { return storage_class & STCauto; }
|
|
122 int isScope() { return storage_class & (STCscope | STCauto); }
|
|
123 int isSynchronized() { return storage_class & STCsynchronized; }
|
|
124 int isParameter() { return storage_class & STCparameter; }
|
|
125 int isDeprecated() { return storage_class & STCdeprecated; }
|
|
126 int isOverride() { return storage_class & STCoverride; }
|
|
127
|
|
128 int isIn() { return storage_class & STCin; }
|
|
129 int isOut() { return storage_class & STCout; }
|
|
130 int isRef() { return storage_class & STCref; }
|
|
131
|
|
132 enum PROT prot();
|
|
133
|
|
134 Declaration *isDeclaration() { return this; }
|
|
135
|
|
136 // llvm
|
|
137 virtual void toObjFile(); // compile to .obj file
|
|
138 };
|
|
139
|
|
140 /**************************************************************/
|
|
141
|
|
142 struct TupleDeclaration : Declaration
|
|
143 {
|
|
144 Objects *objects;
|
|
145 int isexp; // 1: expression tuple
|
|
146
|
|
147 TypeTuple *tupletype; // !=NULL if this is a type tuple
|
|
148
|
|
149 TupleDeclaration(Loc loc, Identifier *ident, Objects *objects);
|
|
150 Dsymbol *syntaxCopy(Dsymbol *);
|
|
151 char *kind();
|
|
152 Type *getType();
|
|
153 int needThis();
|
|
154
|
|
155 TupleDeclaration *isTupleDeclaration() { return this; }
|
|
156 };
|
|
157
|
|
158 /**************************************************************/
|
|
159
|
|
160 struct TypedefDeclaration : Declaration
|
|
161 {
|
|
162 Type *basetype;
|
|
163 Initializer *init;
|
|
164 int sem; // 0: semantic() has not been run
|
|
165 // 1: semantic() is in progress
|
|
166 // 2: semantic() has been run
|
|
167 // 3: semantic2() has been run
|
|
168 int inuse; // used to detect typedef cycles
|
|
169
|
|
170 TypedefDeclaration(Loc loc, Identifier *ident, Type *basetype, Initializer *init);
|
|
171 Dsymbol *syntaxCopy(Dsymbol *);
|
|
172 void semantic(Scope *sc);
|
|
173 void semantic2(Scope *sc);
|
|
174 char *mangle();
|
|
175 char *kind();
|
|
176 Type *getType();
|
|
177 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
178 #ifdef _DH
|
|
179 Type *htype;
|
|
180 Type *hbasetype;
|
|
181 #endif
|
|
182
|
|
183 void toDocBuffer(OutBuffer *buf);
|
|
184
|
|
185 void toObjFile(); // compile to .obj file
|
|
186 void toDebug();
|
|
187 int cvMember(unsigned char *p);
|
|
188
|
|
189 TypedefDeclaration *isTypedefDeclaration() { return this; }
|
|
190
|
|
191 Symbol *sinit;
|
|
192 Symbol *toInitializer();
|
|
193 };
|
|
194
|
|
195 /**************************************************************/
|
|
196
|
|
197 struct AliasDeclaration : Declaration
|
|
198 {
|
|
199 Dsymbol *aliassym;
|
|
200 Dsymbol *overnext; // next in overload list
|
|
201 int inSemantic;
|
|
202
|
|
203 AliasDeclaration(Loc loc, Identifier *ident, Type *type);
|
|
204 AliasDeclaration(Loc loc, Identifier *ident, Dsymbol *s);
|
|
205 Dsymbol *syntaxCopy(Dsymbol *);
|
|
206 void semantic(Scope *sc);
|
|
207 int overloadInsert(Dsymbol *s);
|
|
208 char *kind();
|
|
209 Type *getType();
|
|
210 Dsymbol *toAlias();
|
|
211 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
212 #ifdef _DH
|
|
213 Type *htype;
|
|
214 Dsymbol *haliassym;
|
|
215 #endif
|
|
216
|
|
217 void toDocBuffer(OutBuffer *buf);
|
|
218
|
|
219 AliasDeclaration *isAliasDeclaration() { return this; }
|
|
220 };
|
|
221
|
|
222 /**************************************************************/
|
|
223
|
|
224 struct VarDeclaration : Declaration
|
|
225 {
|
|
226 Initializer *init;
|
|
227 unsigned offset;
|
|
228 int noauto; // no auto semantics
|
|
229 int nestedref; // referenced by a lexically nested function
|
|
230 int inuse;
|
|
231 int ctorinit; // it has been initialized in a ctor
|
|
232 int onstack; // 1: it has been allocated on the stack
|
|
233 // 2: on stack, run destructor anyway
|
|
234 int canassign; // it can be assigned to
|
|
235 Dsymbol *aliassym; // if redone as alias to another symbol
|
|
236 Expression *value; // when interpreting, this is the value
|
|
237 // (NULL if value not determinable)
|
|
238
|
|
239 VarDeclaration(Loc loc, Type *t, Identifier *id, Initializer *init);
|
|
240 Dsymbol *syntaxCopy(Dsymbol *);
|
|
241 void semantic(Scope *sc);
|
|
242 void semantic2(Scope *sc);
|
|
243 char *kind();
|
|
244 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
245 #ifdef _DH
|
|
246 Type *htype;
|
|
247 Initializer *hinit;
|
|
248 #endif
|
|
249 int needThis();
|
|
250 int isImportedSymbol();
|
|
251 int isDataseg();
|
|
252 int hasPointers();
|
|
253 Expression *callAutoDtor();
|
|
254 ExpInitializer *getExpInitializer();
|
|
255 void checkCtorConstInit();
|
|
256 void checkNestedReference(Scope *sc, Loc loc);
|
|
257 Dsymbol *toAlias();
|
|
258
|
|
259 Symbol *toSymbol();
|
|
260 void toObjFile(); // compile to .obj file
|
|
261 int cvMember(unsigned char *p);
|
|
262
|
|
263 // Eliminate need for dynamic_cast
|
|
264 VarDeclaration *isVarDeclaration() { return (VarDeclaration *)this; }
|
|
265
|
|
266 // LLVMDC
|
|
267 bool needsStorage;
|
|
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();
|
|
298
|
|
299 ClassInfoDeclaration* isClassInfoDeclaration() { return this; }
|
|
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; }
|
|
330
|
|
331 // LLVMDC
|
|
332 virtual void llvmDeclare();
|
|
333 virtual void llvmDefine();
|
|
334 };
|
|
335
|
|
336 struct TypeInfoStructDeclaration : TypeInfoDeclaration
|
|
337 {
|
|
338 TypeInfoStructDeclaration(Type *tinfo);
|
|
339
|
|
340 void toDt(dt_t **pdt);
|
|
341
|
|
342 // LLVMDC
|
|
343 void llvmDeclare();
|
|
344 void llvmDefine();
|
|
345 };
|
|
346
|
|
347 struct TypeInfoClassDeclaration : TypeInfoDeclaration
|
|
348 {
|
|
349 TypeInfoClassDeclaration(Type *tinfo);
|
|
350
|
|
351 void toDt(dt_t **pdt);
|
|
352
|
|
353 // LLVMDC
|
|
354 void llvmDeclare();
|
|
355 void llvmDefine();
|
|
356 };
|
|
357
|
|
358 struct TypeInfoInterfaceDeclaration : TypeInfoDeclaration
|
|
359 {
|
|
360 TypeInfoInterfaceDeclaration(Type *tinfo);
|
|
361
|
|
362 void toDt(dt_t **pdt);
|
|
363
|
|
364 // LLVMDC
|
|
365 void llvmDeclare();
|
|
366 void llvmDefine();
|
|
367 };
|
|
368
|
|
369 struct TypeInfoTypedefDeclaration : TypeInfoDeclaration
|
|
370 {
|
|
371 TypeInfoTypedefDeclaration(Type *tinfo);
|
|
372
|
|
373 void toDt(dt_t **pdt);
|
|
374
|
|
375 // LLVMDC
|
|
376 void llvmDeclare();
|
|
377 void llvmDefine();
|
|
378 };
|
|
379
|
|
380 struct TypeInfoPointerDeclaration : TypeInfoDeclaration
|
|
381 {
|
|
382 TypeInfoPointerDeclaration(Type *tinfo);
|
|
383
|
|
384 void toDt(dt_t **pdt);
|
|
385
|
|
386 // LLVMDC
|
|
387 void llvmDeclare();
|
|
388 void llvmDefine();
|
|
389 };
|
|
390
|
|
391 struct TypeInfoArrayDeclaration : TypeInfoDeclaration
|
|
392 {
|
|
393 TypeInfoArrayDeclaration(Type *tinfo);
|
|
394
|
|
395 void toDt(dt_t **pdt);
|
|
396
|
|
397 // LLVMDC
|
|
398 void llvmDeclare();
|
|
399 void llvmDefine();
|
|
400 };
|
|
401
|
|
402 struct TypeInfoStaticArrayDeclaration : TypeInfoDeclaration
|
|
403 {
|
|
404 TypeInfoStaticArrayDeclaration(Type *tinfo);
|
|
405
|
|
406 void toDt(dt_t **pdt);
|
|
407
|
|
408 // LLVMDC
|
|
409 void llvmDeclare();
|
|
410 void llvmDefine();
|
|
411 };
|
|
412
|
|
413 struct TypeInfoAssociativeArrayDeclaration : TypeInfoDeclaration
|
|
414 {
|
|
415 TypeInfoAssociativeArrayDeclaration(Type *tinfo);
|
|
416
|
|
417 void toDt(dt_t **pdt);
|
|
418
|
|
419 // LLVMDC
|
|
420 void llvmDeclare();
|
|
421 void llvmDefine();
|
|
422 };
|
|
423
|
|
424 struct TypeInfoEnumDeclaration : TypeInfoDeclaration
|
|
425 {
|
|
426 TypeInfoEnumDeclaration(Type *tinfo);
|
|
427
|
|
428 void toDt(dt_t **pdt);
|
|
429
|
|
430 // LLVMDC
|
|
431 void llvmDeclare();
|
|
432 void llvmDefine();
|
|
433 };
|
|
434
|
|
435 struct TypeInfoFunctionDeclaration : TypeInfoDeclaration
|
|
436 {
|
|
437 TypeInfoFunctionDeclaration(Type *tinfo);
|
|
438
|
|
439 void toDt(dt_t **pdt);
|
|
440
|
|
441 // LLVMDC
|
|
442 void llvmDeclare();
|
|
443 void llvmDefine();
|
|
444 };
|
|
445
|
|
446 struct TypeInfoDelegateDeclaration : TypeInfoDeclaration
|
|
447 {
|
|
448 TypeInfoDelegateDeclaration(Type *tinfo);
|
|
449
|
|
450 void toDt(dt_t **pdt);
|
|
451
|
|
452 // LLVMDC
|
|
453 void llvmDeclare();
|
|
454 void llvmDefine();
|
|
455 };
|
|
456
|
|
457 struct TypeInfoTupleDeclaration : TypeInfoDeclaration
|
|
458 {
|
|
459 TypeInfoTupleDeclaration(Type *tinfo);
|
|
460
|
|
461 void toDt(dt_t **pdt);
|
|
462
|
|
463 // LLVMDC
|
|
464 void llvmDeclare();
|
|
465 void llvmDefine();
|
|
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
|
|
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
|
|
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 // this function's frame ptr
|
|
530 ForeachStatement *fes; // if foreach body, this is the foreach
|
|
531 int introducing; // !=0 if 'introducing' function
|
|
532 Type *tintro; // if !=NULL, then this is the type
|
|
533 // of the 'introducing' function
|
|
534 // this one is overriding
|
|
535 int inferRetType; // !=0 if return type is to be inferred
|
|
536 Scope *scope; // !=NULL means context to use
|
|
537
|
|
538 // Things that should really go into Scope
|
|
539 int hasReturnExp; // 1 if there's a return exp; statement
|
|
540 // 2 if there's a throw statement
|
|
541 // 4 if there's an assert(0)
|
|
542 // 8 if there's inline asm
|
|
543
|
|
544 // Support for NRVO (named return value optimization)
|
|
545 int nrvo_can; // !=0 means we can do it
|
|
546 VarDeclaration *nrvo_var; // variable to replace with shidden
|
|
547 Symbol *shidden; // hidden pointer passed to function
|
|
548
|
|
549 #if V2
|
|
550 enum BUILTIN builtin; // set if this is a known, builtin
|
|
551 // function we can evaluate at compile
|
|
552 // time
|
|
553
|
|
554 int tookAddressOf; // set if someone took the address of
|
|
555 // this function
|
|
556 Dsymbols closureVars; // local variables in this function
|
|
557 // which are referenced by nested
|
|
558 // functions
|
|
559 #else
|
|
560 int nestedFrameRef; // !=0 if nested variables referenced
|
|
561 #endif
|
|
562
|
|
563 FuncDeclaration(Loc loc, Loc endloc, Identifier *id, enum STC storage_class, Type *type);
|
|
564 Dsymbol *syntaxCopy(Dsymbol *);
|
|
565 void semantic(Scope *sc);
|
|
566 void semantic2(Scope *sc);
|
|
567 void semantic3(Scope *sc);
|
|
568 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
569 void bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
570 int overrides(FuncDeclaration *fd);
|
|
571 int findVtblIndex(Array *vtbl, int dim);
|
|
572 int overloadInsert(Dsymbol *s);
|
|
573 FuncDeclaration *overloadExactMatch(Type *t);
|
|
574 FuncDeclaration *overloadResolve(Loc loc, Expressions *arguments);
|
|
575 LabelDsymbol *searchLabel(Identifier *ident);
|
|
576 AggregateDeclaration *isThis();
|
|
577 AggregateDeclaration *isMember2();
|
|
578 int getLevel(Loc loc, FuncDeclaration *fd); // lexical nesting level difference
|
|
579 void appendExp(Expression *e);
|
|
580 void appendState(Statement *s);
|
|
581 char *mangle();
|
|
582 int isMain();
|
|
583 int isWinMain();
|
|
584 int isDllMain();
|
|
585 int isExport();
|
|
586 int isImportedSymbol();
|
|
587 int isAbstract();
|
|
588 int isCodeseg();
|
|
589 virtual int isNested();
|
|
590 int needThis();
|
|
591 virtual int isVirtual();
|
|
592 virtual int addPreInvariant();
|
|
593 virtual int addPostInvariant();
|
|
594 Expression *interpret(InterState *istate, Expressions *arguments);
|
|
595 void inlineScan();
|
|
596 int canInline(int hasthis, int hdrscan = 0);
|
|
597 Expression *doInline(InlineScanState *iss, Expression *ethis, Array *arguments);
|
|
598 char *kind();
|
|
599 void toDocBuffer(OutBuffer *buf);
|
|
600
|
|
601 static FuncDeclaration *genCfunc(Type *treturn, char *name);
|
|
602 static FuncDeclaration *genCfunc(Type *treturn, Identifier *id);
|
|
603
|
|
604 Symbol *toSymbol();
|
|
605 Symbol *toThunkSymbol(int offset); // thunk version
|
|
606 void toObjFile(); // compile to .obj file
|
|
607 int cvMember(unsigned char *p);
|
|
608
|
|
609 FuncDeclaration *isFuncDeclaration() { return this; }
|
|
610
|
|
611 // llvmdc stuff
|
|
612 bool runTimeHack;
|
|
613 std::set<VarDeclaration*> nestedVars;
|
|
614 };
|
|
615
|
|
616 struct FuncAliasDeclaration : FuncDeclaration
|
|
617 {
|
|
618 FuncDeclaration *funcalias;
|
|
619
|
|
620 FuncAliasDeclaration(FuncDeclaration *funcalias);
|
|
621
|
|
622 FuncAliasDeclaration *isFuncAliasDeclaration() { return this; }
|
|
623 char *kind();
|
|
624 Symbol *toSymbol();
|
|
625 };
|
|
626
|
|
627 struct FuncLiteralDeclaration : FuncDeclaration
|
|
628 {
|
|
629 enum TOK tok; // TOKfunction or TOKdelegate
|
|
630
|
|
631 FuncLiteralDeclaration(Loc loc, Loc endloc, Type *type, enum TOK tok,
|
|
632 ForeachStatement *fes);
|
|
633 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
634 Dsymbol *syntaxCopy(Dsymbol *);
|
|
635 int isNested();
|
|
636
|
|
637 FuncLiteralDeclaration *isFuncLiteralDeclaration() { return this; }
|
|
638 char *kind();
|
|
639 };
|
|
640
|
|
641 struct CtorDeclaration : FuncDeclaration
|
|
642 { Arguments *arguments;
|
|
643 int varargs;
|
|
644
|
|
645 CtorDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs);
|
|
646 Dsymbol *syntaxCopy(Dsymbol *);
|
|
647 void semantic(Scope *sc);
|
|
648 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
649 char *kind();
|
|
650 char *toChars();
|
|
651 int isVirtual();
|
|
652 int addPreInvariant();
|
|
653 int addPostInvariant();
|
|
654 void toDocBuffer(OutBuffer *buf);
|
|
655
|
|
656 CtorDeclaration *isCtorDeclaration() { return this; }
|
|
657 };
|
|
658
|
|
659 struct DtorDeclaration : FuncDeclaration
|
|
660 {
|
|
661 DtorDeclaration(Loc loc, Loc endloc);
|
|
662 DtorDeclaration(Loc loc, Loc endloc, Identifier *id);
|
|
663 Dsymbol *syntaxCopy(Dsymbol *);
|
|
664 void semantic(Scope *sc);
|
|
665 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
666 int isVirtual();
|
|
667 int addPreInvariant();
|
|
668 int addPostInvariant();
|
|
669 int overloadInsert(Dsymbol *s);
|
|
670 void emitComment(Scope *sc);
|
|
671
|
|
672 DtorDeclaration *isDtorDeclaration() { return this; }
|
|
673 };
|
|
674
|
|
675 struct StaticCtorDeclaration : FuncDeclaration
|
|
676 {
|
|
677 StaticCtorDeclaration(Loc loc, Loc endloc);
|
|
678 Dsymbol *syntaxCopy(Dsymbol *);
|
|
679 void semantic(Scope *sc);
|
|
680 AggregateDeclaration *isThis();
|
|
681 int isStaticConstructor();
|
|
682 int isVirtual();
|
|
683 int addPreInvariant();
|
|
684 int addPostInvariant();
|
|
685 void emitComment(Scope *sc);
|
|
686 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
687
|
|
688 StaticCtorDeclaration *isStaticCtorDeclaration() { return this; }
|
|
689 };
|
|
690
|
|
691 struct StaticDtorDeclaration : FuncDeclaration
|
|
692 {
|
|
693 StaticDtorDeclaration(Loc loc, Loc endloc);
|
|
694 Dsymbol *syntaxCopy(Dsymbol *);
|
|
695 void semantic(Scope *sc);
|
|
696 AggregateDeclaration *isThis();
|
|
697 int isStaticDestructor();
|
|
698 int isVirtual();
|
|
699 int addPreInvariant();
|
|
700 int addPostInvariant();
|
|
701 void emitComment(Scope *sc);
|
|
702 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
703
|
|
704 StaticDtorDeclaration *isStaticDtorDeclaration() { return this; }
|
|
705 };
|
|
706
|
|
707 struct InvariantDeclaration : FuncDeclaration
|
|
708 {
|
|
709 InvariantDeclaration(Loc loc, Loc endloc);
|
|
710 Dsymbol *syntaxCopy(Dsymbol *);
|
|
711 void semantic(Scope *sc);
|
|
712 int isVirtual();
|
|
713 int addPreInvariant();
|
|
714 int addPostInvariant();
|
|
715 void emitComment(Scope *sc);
|
|
716 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
717
|
|
718 InvariantDeclaration *isInvariantDeclaration() { return this; }
|
|
719 };
|
|
720
|
|
721
|
|
722 struct UnitTestDeclaration : FuncDeclaration
|
|
723 {
|
|
724 UnitTestDeclaration(Loc loc, Loc endloc);
|
|
725 Dsymbol *syntaxCopy(Dsymbol *);
|
|
726 void semantic(Scope *sc);
|
|
727 AggregateDeclaration *isThis();
|
|
728 int isVirtual();
|
|
729 int addPreInvariant();
|
|
730 int addPostInvariant();
|
|
731 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
732
|
|
733 UnitTestDeclaration *isUnitTestDeclaration() { return this; }
|
|
734 };
|
|
735
|
|
736 struct NewDeclaration : FuncDeclaration
|
|
737 { Arguments *arguments;
|
|
738 int varargs;
|
|
739
|
|
740 NewDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs);
|
|
741 Dsymbol *syntaxCopy(Dsymbol *);
|
|
742 void semantic(Scope *sc);
|
|
743 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
744 char *kind();
|
|
745 int isVirtual();
|
|
746 int addPreInvariant();
|
|
747 int addPostInvariant();
|
|
748
|
|
749 NewDeclaration *isNewDeclaration() { return this; }
|
|
750 };
|
|
751
|
|
752
|
|
753 struct DeleteDeclaration : FuncDeclaration
|
|
754 { Arguments *arguments;
|
|
755
|
|
756 DeleteDeclaration(Loc loc, Loc endloc, Arguments *arguments);
|
|
757 Dsymbol *syntaxCopy(Dsymbol *);
|
|
758 void semantic(Scope *sc);
|
|
759 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
|
760 char *kind();
|
|
761 int isDelete();
|
|
762 int isVirtual();
|
|
763 int addPreInvariant();
|
|
764 int addPostInvariant();
|
|
765 #ifdef _DH
|
|
766 DeleteDeclaration *isDeleteDeclaration() { return this; }
|
|
767 #endif
|
|
768 };
|
|
769
|
|
770 #endif /* DMD_DECLARATION_H */
|