root/trunk/src/declaration.h

Revision 785, 26.0 kB (checked in by walter, 1 year ago)

bugzilla 4217 Function overloads are not distinguished when instantiating templates

  • Property svn:eol-style set to native
Line 
1 // Compiler implementation of the D programming language
2 // Copyright (c) 1999-2010 by Digital Mars
3 // All Rights Reserved
4 // written by Walter Bright
5 // http://www.digitalmars.com
6 // License for redistribution is by either the Artistic License
7 // in artistic.txt, or the GNU General Public License in gnu.txt.
8 // See the included readme.txt for details.
9
10 #ifndef DMD_DECLARATION_H
11 #define DMD_DECLARATION_H
12
13 #ifdef __DMC__
14 #pragma once
15 #endif /* __DMC__ */
16
17 #include "dsymbol.h"
18 #include "lexer.h"
19 #include "mtype.h"
20
21 struct Expression;
22 struct Statement;
23 struct LabelDsymbol;
24 struct Initializer;
25 struct Module;
26 struct InlineScanState;
27 struct ForeachStatement;
28 struct FuncDeclaration;
29 struct ExpInitializer;
30 struct StructDeclaration;
31 struct TupleType;
32 struct InterState;
33 struct IRState;
34
35 enum PROT;
36 enum LINK;
37 enum TOK;
38 enum MATCH;
39 enum PURE;
40
41 #define STCundefined    0LL
42 #define STCstatic       1LL
43 #define STCextern       2LL
44 #define STCconst        4LL
45 #define STCfinal        8LL
46 #define STCabstract     0x10LL
47 #define STCparameter    0x20LL
48 #define STCfield        0x40LL
49 #define STCoverride     0x80LL
50 #define STCauto         0x100LL
51 #define STCsynchronized 0x200LL
52 #define STCdeprecated   0x400LL
53 #define STCin           0x800LL         // in parameter
54 #define STCout          0x1000LL        // out parameter
55 #define STClazy         0x2000LL        // lazy parameter
56 #define STCforeach      0x4000LL        // variable for foreach loop
57 #define STCcomdat       0x8000LL        // should go into COMDAT record
58 #define STCvariadic     0x10000LL       // variadic function argument
59 #define STCctorinit     0x20000LL       // can only be set inside constructor
60 #define STCtemplateparameter  0x40000LL // template parameter
61 #define STCscope        0x80000LL       // template parameter
62 #define STCimmutable    0x100000LL
63 #define STCref          0x200000LL
64 #define STCinit         0x400000LL      // has explicit initializer
65 #define STCmanifest     0x800000LL      // manifest constant
66 #define STCnodtor       0x1000000LL     // don't run destructor
67 #define STCnothrow      0x2000000LL     // never throws exceptions
68 #define STCpure         0x4000000LL     // pure function
69 #define STCtls          0x8000000LL     // thread local
70 #define STCalias        0x10000000LL    // alias parameter
71 #define STCshared       0x20000000LL    // accessible from multiple threads
72 #define STCgshared      0x40000000LL    // accessible from multiple threads
73                                         // but not typed as "shared"
74 #define STCwild         0x80000000LL    // for "wild" type constructor
75 #define STC_TYPECTOR    (STCconst | STCimmutable | STCshared | STCwild)
76
77 #define STCproperty     0x100000000LL
78 #define STCsafe         0x200000000LL
79 #define STCtrusted      0x400000000LL
80 #define STCsystem       0x800000000LL
81 #define STCctfe         0x1000000000LL  // can be used in CTFE, even if it is static
82 #define STCdisable      0x2000000000LL  // for functions that are not callable
83 #define STCresult       0x4000000000LL  // for result variables passed to out contracts
84
85 struct Match
86 {
87     int count;                  // number of matches found
88     MATCH last;                 // match level of lastf
89     FuncDeclaration *lastf;     // last matching function we found
90     FuncDeclaration *nextf;     // current matching function
91     FuncDeclaration *anyf;      // pick a func, any func, to use for error recovery
92 };
93
94 void overloadResolveX(Match *m, FuncDeclaration *f,
95         Expression *ethis, Expressions *arguments);
96 int overloadApply(FuncDeclaration *fstart,
97         int (*fp)(void *, FuncDeclaration *),
98         void *param);
99
100 enum Semantic
101 {
102     SemanticStart,      // semantic has not been run
103     SemanticIn,         // semantic() is in progress
104     SemanticDone,       // semantic() has been run
105     Semantic2Done,      // semantic2() has been run
106 };
107
108 /**************************************************************/
109
110 struct Declaration : Dsymbol
111 {
112     Type *type;
113     Type *originalType;         // before semantic analysis
114     StorageClass storage_class;
115     enum PROT protection;
116     enum LINK linkage;
117     int inuse;                  // used to detect cycles
118
119     enum Semantic sem;
120
121     Declaration(Identifier *id);
122     void semantic(Scope *sc);
123     const char *kind();
124     unsigned size(Loc loc);
125     void checkModify(Loc loc, Scope *sc, Type *t);
126
127     void emitComment(Scope *sc);
128     void toJsonBuffer(OutBuffer *buf);
129     void toDocBuffer(OutBuffer *buf);
130
131     char *mangle();
132     int isStatic() { return storage_class & STCstatic; }
133     virtual int isDelete();
134     virtual int isDataseg();
135     virtual int isThreadlocal();
136     virtual int isCodeseg();
137     int isCtorinit()     { return storage_class & STCctorinit; }
138     int isFinal()        { return storage_class & STCfinal; }
139     int isAbstract()     { return storage_class & STCabstract; }
140     int isConst()        { return storage_class & STCconst; }
141     int isImmutable()    { return storage_class & STCimmutable; }
142     int isAuto()         { return storage_class & STCauto; }
143     int isScope()        { return storage_class & STCscope; }
144     int isSynchronized() { return storage_class & STCsynchronized; }
145     int isParameter()    { return storage_class & STCparameter; }
146     int isDeprecated()   { return storage_class & STCdeprecated; }
147     int isOverride()     { return storage_class & STCoverride; }
148     int isResult()       { return storage_class & STCresult; }
149
150     int isIn()    { return storage_class & STCin; }
151     int isOut()   { return storage_class & STCout; }
152     int isRef()   { return storage_class & STCref; }
153
154     enum PROT prot();
155
156     Declaration *isDeclaration() { return this; }
157 };
158
159 /**************************************************************/
160
161 struct TupleDeclaration : Declaration
162 {
163     Objects *objects;
164     int isexp;                  // 1: expression tuple
165
166     TypeTuple *tupletype;       // !=NULL if this is a type tuple
167
168     TupleDeclaration(Loc loc, Identifier *ident, Objects *objects);
169     Dsymbol *syntaxCopy(Dsymbol *);
170     const char *kind();
171     Type *getType();
172     int needThis();
173
174     TupleDeclaration *isTupleDeclaration() { return this; }
175 };
176
177 /**************************************************************/
178
179 struct TypedefDeclaration : Declaration
180 {
181     Type *basetype;
182     Initializer *init;
183
184     TypedefDeclaration(Loc loc, Identifier *ident, Type *basetype, Initializer *init);
185     Dsymbol *syntaxCopy(Dsymbol *);
186     void semantic(Scope *sc);
187     void semantic2(Scope *sc);
188     char *mangle();
189     const char *kind();
190     Type *getType();
191     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
192 #ifdef _DH
193     Type *htype;
194     Type *hbasetype;
195 #endif
196
197     void toDocBuffer(OutBuffer *buf);
198
199     void toObjFile(int multiobj);                       // compile to .obj file
200     void toDebug();
201     int cvMember(unsigned char *p);
202
203     TypedefDeclaration *isTypedefDeclaration() { return this; }
204
205     Symbol *sinit;
206     Symbol *toInitializer();
207 };
208
209 /**************************************************************/
210
211 struct AliasDeclaration : Declaration
212 {
213     Dsymbol *aliassym;
214     Dsymbol *overnext;          // next in overload list
215     int inSemantic;
216
217     AliasDeclaration(Loc loc, Identifier *ident, Type *type);
218     AliasDeclaration(Loc loc, Identifier *ident, Dsymbol *s);
219     Dsymbol *syntaxCopy(Dsymbol *);
220     void semantic(Scope *sc);
221     int overloadInsert(Dsymbol *s);
222     const char *kind();
223     Type *getType();
224     Dsymbol *toAlias();
225     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
226 #ifdef _DH
227     Type *htype;
228     Dsymbol *haliassym;
229 #endif
230
231     void toDocBuffer(OutBuffer *buf);
232
233     AliasDeclaration *isAliasDeclaration() { return this; }
234 };
235
236 /**************************************************************/
237
238 struct VarDeclaration : Declaration
239 {
240     Initializer *init;
241     unsigned offset;
242     int noscope;                 // no auto semantics
243 #if DMDV2
244     FuncDeclarations nestedrefs; // referenced by these lexically nested functions
245     bool isargptr;              // if parameter that _argptr points to
246 #else
247     int nestedref;              // referenced by a lexically nested function
248 #endif
249     int ctorinit;               // it has been initialized in a ctor
250     int onstack;                // 1: it has been allocated on the stack
251                                 // 2: on stack, run destructor anyway
252     int canassign;              // it can be assigned to
253     Dsymbol *aliassym;          // if redone as alias to another symbol
254     Expression *value;          // when interpreting, this is the value
255                                 // (NULL if value not determinable)
256 #if DMDV2
257     VarDeclaration *rundtor;    // if !NULL, rundtor is tested at runtime to see
258                                 // if the destructor should be run. Used to prevent
259                                 // dtor calls on postblitted vars
260 #endif
261
262     VarDeclaration(Loc loc, Type *t, Identifier *id, Initializer *init);
263     Dsymbol *syntaxCopy(Dsymbol *);
264     void semantic(Scope *sc);
265     void semantic2(Scope *sc);
266     const char *kind();
267     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
268 #ifdef _DH
269     Type *htype;
270     Initializer *hinit;
271 #endif
272     AggregateDeclaration *isThis();
273     int needThis();
274     int isImportedSymbol();
275     int isDataseg();
276     int isThreadlocal();
277     int isCTFE();
278     int hasPointers();
279 #if DMDV2
280     int canTakeAddressOf();
281     int needsAutoDtor();
282 #endif
283     Expression *callScopeDtor(Scope *sc);
284     ExpInitializer *getExpInitializer();
285     Expression *getConstInitializer();
286     void checkCtorConstInit();
287     void checkNestedReference(Scope *sc, Loc loc);
288     Dsymbol *toAlias();
289
290     Symbol *toSymbol();
291     void toObjFile(int multiobj);                       // compile to .obj file
292     int cvMember(unsigned char *p);
293
294     // Eliminate need for dynamic_cast
295     VarDeclaration *isVarDeclaration() { return (VarDeclaration *)this; }
296 };
297
298 /**************************************************************/
299
300 // This is a shell around a back end symbol
301
302 struct SymbolDeclaration : Declaration
303 {
304     Symbol *sym;
305     StructDeclaration *dsym;
306
307     SymbolDeclaration(Loc loc, Symbol *s, StructDeclaration *dsym);
308
309     Symbol *toSymbol();
310
311     // Eliminate need for dynamic_cast
312     SymbolDeclaration *isSymbolDeclaration() { return (SymbolDeclaration *)this; }
313 };
314
315 struct ClassInfoDeclaration : VarDeclaration
316 {
317     ClassDeclaration *cd;
318
319     ClassInfoDeclaration(ClassDeclaration *cd);
320     Dsymbol *syntaxCopy(Dsymbol *);
321     void semantic(Scope *sc);
322
323     void emitComment(Scope *sc);
324     void toJsonBuffer(OutBuffer *buf);
325
326     Symbol *toSymbol();
327 };
328
329 struct ModuleInfoDeclaration : VarDeclaration
330 {
331     Module *mod;
332
333     ModuleInfoDeclaration(Module *mod);
334     Dsymbol *syntaxCopy(Dsymbol *);
335     void semantic(Scope *sc);
336
337     void emitComment(Scope *sc);
338     void toJsonBuffer(OutBuffer *buf);
339
340     Symbol *toSymbol();
341 };
342
343 struct TypeInfoDeclaration : VarDeclaration
344 {
345     Type *tinfo;
346
347     TypeInfoDeclaration(Type *tinfo, int internal);
348     Dsymbol *syntaxCopy(Dsymbol *);
349     void semantic(Scope *sc);
350
351     void emitComment(Scope *sc);
352     void toJsonBuffer(OutBuffer *buf);
353
354     Symbol *toSymbol();
355     void toObjFile(int multiobj);                       // compile to .obj file
356     virtual void toDt(dt_t **pdt);
357 };
358
359 struct TypeInfoStructDeclaration : TypeInfoDeclaration
360 {
361     TypeInfoStructDeclaration(Type *tinfo);
362
363     void toDt(dt_t **pdt);
364 };
365
366 struct TypeInfoClassDeclaration : TypeInfoDeclaration
367 {
368     TypeInfoClassDeclaration(Type *tinfo);
369     Symbol *toSymbol();
370
371     void toDt(dt_t **pdt);
372 };
373
374 struct TypeInfoInterfaceDeclaration : TypeInfoDeclaration
375 {
376     TypeInfoInterfaceDeclaration(Type *tinfo);
377
378     void toDt(dt_t **pdt);
379 };
380
381 struct TypeInfoTypedefDeclaration : TypeInfoDeclaration
382 {
383     TypeInfoTypedefDeclaration(Type *tinfo);
384
385     void toDt(dt_t **pdt);
386 };
387
388 struct TypeInfoPointerDeclaration : TypeInfoDeclaration
389 {
390     TypeInfoPointerDeclaration(Type *tinfo);
391
392     void toDt(dt_t **pdt);
393 };
394
395 struct TypeInfoArrayDeclaration : TypeInfoDeclaration
396 {
397     TypeInfoArrayDeclaration(Type *tinfo);
398
399     void toDt(dt_t **pdt);
400 };
401
402 struct TypeInfoStaticArrayDeclaration : TypeInfoDeclaration
403 {
404     TypeInfoStaticArrayDeclaration(Type *tinfo);
405
406     void toDt(dt_t **pdt);
407 };
408
409 struct TypeInfoAssociativeArrayDeclaration : TypeInfoDeclaration
410 {
411     TypeInfoAssociativeArrayDeclaration(Type *tinfo);
412
413     void toDt(dt_t **pdt);
414 };
415
416 struct TypeInfoEnumDeclaration : TypeInfoDeclaration
417 {
418     TypeInfoEnumDeclaration(Type *tinfo);
419
420     void toDt(dt_t **pdt);
421 };
422
423 struct TypeInfoFunctionDeclaration : TypeInfoDeclaration
424 {
425     TypeInfoFunctionDeclaration(Type *tinfo);
426
427     void toDt(dt_t **pdt);
428 };
429
430 struct TypeInfoDelegateDeclaration : TypeInfoDeclaration
431 {
432     TypeInfoDelegateDeclaration(Type *tinfo);
433
434     void toDt(dt_t **pdt);
435 };
436
437 struct TypeInfoTupleDeclaration : TypeInfoDeclaration
438 {
439     TypeInfoTupleDeclaration(Type *tinfo);
440
441     void toDt(dt_t **pdt);
442 };
443
444 #if DMDV2
445 struct TypeInfoConstDeclaration : TypeInfoDeclaration
446 {
447     TypeInfoConstDeclaration(Type *tinfo);
448
449     void toDt(dt_t **pdt);
450 };
451
452 struct TypeInfoInvariantDeclaration : TypeInfoDeclaration
453 {
454     TypeInfoInvariantDeclaration(Type *tinfo);
455
456     void toDt(dt_t **pdt);
457 };
458
459 struct TypeInfoSharedDeclaration : TypeInfoDeclaration
460 {
461     TypeInfoSharedDeclaration(Type *tinfo);
462
463     void toDt(dt_t **pdt);
464 };
465
466 struct TypeInfoWildDeclaration : TypeInfoDeclaration
467 {
468     TypeInfoWildDeclaration(Type *tinfo);
469
470     void toDt(dt_t **pdt);
471 };
472 #endif
473
474 /**************************************************************/
475
476 struct ThisDeclaration : VarDeclaration
477 {
478     ThisDeclaration(Loc loc, Type *t);
479     Dsymbol *syntaxCopy(Dsymbol *);
480     ThisDeclaration *isThisDeclaration() { return this; }
481 };
482
483 enum ILS
484 {
485     ILSuninitialized,   // not computed yet
486     ILSno,              // cannot inline
487     ILSyes,             // can inline
488 };
489
490 /**************************************************************/
491 #if DMDV2
492
493 enum BUILTIN
494 {
495     BUILTINunknown = -1,        // not known if this is a builtin
496     BUILTINnot,                 // this is not a builtin
497     BUILTINsin,                 // std.math.sin
498     BUILTINcos,                 // std.math.cos
499     BUILTINtan,                 // std.math.tan
500     BUILTINsqrt,                // std.math.sqrt
501     BUILTINfabs,                // std.math.fabs
502 };
503
504 Expression *eval_builtin(enum BUILTIN builtin, Expressions *arguments);
505
506 #else
507 enum BUILTIN { };
508 #endif
509
510 struct FuncDeclaration : Declaration
511 {
512     Array *fthrows;                     // Array of Type's of exceptions (not used)
513     Statement *frequire;
514     Statement *fensure;
515     Statement *fbody;
516
517     FuncDeclarations foverrides;        // functions this function overrides
518     FuncDeclaration *fdrequire;         // function that does the in contract
519     FuncDeclaration *fdensure;          // function that does the out contract
520
521     Identifier *outId;                  // identifier for out statement
522     VarDeclaration *vresult;            // variable corresponding to outId
523     LabelDsymbol *returnLabel;          // where the return goes
524
525     DsymbolTable *localsymtab;          // used to prevent symbols in different
526                                         // scopes from having the same name
527     VarDeclaration *vthis;              // 'this' parameter (member and nested)
528     VarDeclaration *v_arguments;        // '_arguments' parameter
529 #if IN_GCC
530     VarDeclaration *v_argptr;           // '_argptr' variable
531 #endif
532     VarDeclaration *v_argsave;          // save area for args passed in registers for variadic functions
533     Dsymbols *parameters;               // Array of VarDeclaration's for parameters
534     DsymbolTable *labtab;               // statement label symbol table
535     Declaration *overnext;              // next in overload list
536     Loc endloc;                         // location of closing curly bracket
537     int vtblIndex;                      // for member functions, index into vtbl[]
538     int naked;                          // !=0 if naked
539     int inlineAsm;                      // !=0 if has inline assembler
540     ILS inlineStatus;
541     int inlineNest;                     // !=0 if nested inline
542     int cantInterpret;                  // !=0 if cannot interpret function
543     enum PASS semanticRun;
544                                         // this function's frame ptr
545     ForeachStatement *fes;              // if foreach body, this is the foreach
546     int introducing;                    // !=0 if 'introducing' function
547     Type *tintro;                       // if !=NULL, then this is the type
548                                         // of the 'introducing' function
549                                         // this one is overriding
550     int inferRetType;                   // !=0 if return type is to be inferred
551
552     // Things that should really go into Scope
553     int hasReturnExp;                   // 1 if there's a return exp; statement
554                                         // 2 if there's a throw statement
555                                         // 4 if there's an assert(0)
556                                         // 8 if there's inline asm
557
558     // Support for NRVO (named return value optimization)
559     int nrvo_can;                       // !=0 means we can do it
560     VarDeclaration *nrvo_var;           // variable to replace with shidden
561     Symbol *shidden;                    // hidden pointer passed to function
562
563 #if DMDV2
564     enum BUILTIN builtin;               // set if this is a known, builtin
565                                         // function we can evaluate at compile
566                                         // time
567
568     int tookAddressOf;                  // set if someone took the address of
569                                         // this function
570     Dsymbols closureVars;               // local variables in this function
571                                         // which are referenced by nested
572                                         // functions
573 #else
574     int nestedFrameRef;                 // !=0 if nested variables referenced
575 #endif
576
577     FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageClass storage_class, Type *type);
578     Dsymbol *syntaxCopy(Dsymbol *);
579     void semantic(Scope *sc);
580     void semantic2(Scope *sc);
581     void semantic3(Scope *sc);
582     // called from semantic3
583     void varArgs(Scope *sc, TypeFunction*, VarDeclaration *&, VarDeclaration *&);
584     int equals(Object *o);
585
586     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
587     void bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs);
588     int overrides(FuncDeclaration *fd);
589     int findVtblIndex(Array *vtbl, int dim);
590     int overloadInsert(Dsymbol *s);
591     FuncDeclaration *overloadExactMatch(Type *t);
592     FuncDeclaration *overloadResolve(Loc loc, Expression *ethis, Expressions *arguments, int flags = 0);
593     MATCH leastAsSpecialized(FuncDeclaration *g);
594     LabelDsymbol *searchLabel(Identifier *ident);
595     AggregateDeclaration *isThis();
596     AggregateDeclaration *isMember2();
597     int getLevel(Loc loc, FuncDeclaration *fd); // lexical nesting level difference
598     void appendExp(Expression *e);
599     void appendState(Statement *s);
600     char *mangle();
601     const char *toPrettyChars();
602     int isMain();
603     int isWinMain();
604     int isDllMain();
605     enum BUILTIN isBuiltin();
606     int isExport();
607     int isImportedSymbol();
608     int isAbstract();
609     int isCodeseg();
610     int isOverloadable();
611     enum PURE isPure();
612     int isSafe();
613     int isTrusted();
614     virtual int isNested();
615     int needThis();
616     virtual int isVirtual();
617     virtual int isFinal();
618     virtual int addPreInvariant();
619     virtual int addPostInvariant();
620     Expression *interpret(InterState *istate, Expressions *arguments, Expression *thisexp = NULL);
621     void inlineScan();
622     int canInline(int hasthis, int hdrscan = 0);
623     Expression *doInline(InlineScanState *iss, Expression *ethis, Array *arguments);
624     const char *kind();
625     void toDocBuffer(OutBuffer *buf);
626     FuncDeclaration *isUnique();
627     int needsClosure();
628     Statement *mergeFrequire(Statement *);
629     Statement *mergeFensure(Statement *);
630     Parameters *getParameters(int *pvarargs);
631
632     static FuncDeclaration *genCfunc(Type *treturn, const char *name);
633     static FuncDeclaration *genCfunc(Type *treturn, Identifier *id);
634
635     Symbol *toSymbol();
636     Symbol *toThunkSymbol(int offset);  // thunk version
637     void toObjFile(int multiobj);                       // compile to .obj file
638     int cvMember(unsigned char *p);
639     void buildClosure(IRState *irs);
640
641     FuncDeclaration *isFuncDeclaration() { return this; }
642 };
643
644 #if DMDV2
645 FuncDeclaration *resolveFuncCall(Scope *sc, Loc loc, Dsymbol *s,
646         Objects *tiargs,
647         Expression *ethis,
648         Expressions *arguments,
649         int flags);
650 #endif
651
652 struct FuncAliasDeclaration : FuncDeclaration
653 {
654     FuncDeclaration *funcalias;
655
656     FuncAliasDeclaration(FuncDeclaration *funcalias);
657
658     FuncAliasDeclaration *isFuncAliasDeclaration() { return this; }
659     const char *kind();
660     Symbol *toSymbol();
661 };
662
663 struct FuncLiteralDeclaration : FuncDeclaration
664 {
665     enum TOK tok;                       // TOKfunction or TOKdelegate
666
667     FuncLiteralDeclaration(Loc loc, Loc endloc, Type *type, enum TOK tok,
668         ForeachStatement *fes);
669     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
670     Dsymbol *syntaxCopy(Dsymbol *);
671     int isNested();
672     int isVirtual();
673
674     FuncLiteralDeclaration *isFuncLiteralDeclaration() { return this; }
675     const char *kind();
676 };
677
678 struct CtorDeclaration : FuncDeclaration
679 {   Parameters *arguments;
680     int varargs;
681
682     CtorDeclaration(Loc loc, Loc endloc, Parameters *arguments, int varargs, StorageClass stc);
683     Dsymbol *syntaxCopy(Dsymbol *);
684     void semantic(Scope *sc);
685     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
686     const char *kind();
687     char *toChars();
688     int isVirtual();
689     int addPreInvariant();
690     int addPostInvariant();
691
692     CtorDeclaration *isCtorDeclaration() { return this; }
693 };
694
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     void toJsonBuffer(OutBuffer *buf);
709
710     PostBlitDeclaration *isPostBlitDeclaration() { return this; }
711 };
712 #endif
713
714 struct DtorDeclaration : FuncDeclaration
715 {
716     DtorDeclaration(Loc loc, Loc endloc);
717     DtorDeclaration(Loc loc, Loc endloc, Identifier *id);
718     Dsymbol *syntaxCopy(Dsymbol *);
719     void semantic(Scope *sc);
720     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
721     const char *kind();
722     char *toChars();
723     int isVirtual();
724     int addPreInvariant();
725     int addPostInvariant();
726     int overloadInsert(Dsymbol *s);
727     void emitComment(Scope *sc);
728     void toJsonBuffer(OutBuffer *buf);
729
730     DtorDeclaration *isDtorDeclaration() { return this; }
731 };
732
733 struct StaticCtorDeclaration : FuncDeclaration
734 {
735     StaticCtorDeclaration(Loc loc, Loc endloc);
736     StaticCtorDeclaration(Loc loc, Loc endloc, const char *name);
737     Dsymbol *syntaxCopy(Dsymbol *);
738     void semantic(Scope *sc);
739     AggregateDeclaration *isThis();
740     int isVirtual();
741     int addPreInvariant();
742     int addPostInvariant();
743     void emitComment(Scope *sc);
744     void toJsonBuffer(OutBuffer *buf);
745     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
746
747     StaticCtorDeclaration *isStaticCtorDeclaration() { return this; }
748 };
749
750 #if DMDV2
751 struct SharedStaticCtorDeclaration : StaticCtorDeclaration
752 {
753     SharedStaticCtorDeclaration(Loc loc, Loc endloc);
754     Dsymbol *syntaxCopy(Dsymbol *);
755     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
756
757     SharedStaticCtorDeclaration *isSharedStaticCtorDeclaration() { return this; }
758 };
759 #endif
760
761 struct StaticDtorDeclaration : FuncDeclaration
762 {   VarDeclaration *vgate;      // 'gate' variable
763
764     StaticDtorDeclaration(Loc loc, Loc endloc);
765     StaticDtorDeclaration(Loc loc, Loc endloc, const char *name);
766     Dsymbol *syntaxCopy(Dsymbol *);
767     void semantic(Scope *sc);
768     AggregateDeclaration *isThis();
769     int isVirtual();
770     int addPreInvariant();
771     int addPostInvariant();
772     void emitComment(Scope *sc);
773     void toJsonBuffer(OutBuffer *buf);
774     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
775
776     StaticDtorDeclaration *isStaticDtorDeclaration() { return this; }
777 };
778
779 #if DMDV2
780 struct SharedStaticDtorDeclaration : StaticDtorDeclaration
781 {
782     SharedStaticDtorDeclaration(Loc loc, Loc endloc);
783     Dsymbol *syntaxCopy(Dsymbol *);
784     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
785
786     SharedStaticDtorDeclaration *isSharedStaticDtorDeclaration() { return this; }
787 };
788 #endif
789
790 struct InvariantDeclaration : FuncDeclaration
791 {
792     InvariantDeclaration(Loc loc, Loc endloc);
793     Dsymbol *syntaxCopy(Dsymbol *);
794     void semantic(Scope *sc);
795     int isVirtual();
796     int addPreInvariant();
797     int addPostInvariant();
798     void emitComment(Scope *sc);
799     void toJsonBuffer(OutBuffer *buf);
800     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
801
802     InvariantDeclaration *isInvariantDeclaration() { return this; }
803 };
804
805 struct UnitTestDeclaration : FuncDeclaration
806 {
807     UnitTestDeclaration(Loc loc, Loc endloc);
808     Dsymbol *syntaxCopy(Dsymbol *);
809     void semantic(Scope *sc);
810     AggregateDeclaration *isThis();
811     int isVirtual();
812     int addPreInvariant();
813     int addPostInvariant();
814     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
815     void toJsonBuffer(OutBuffer *buf);
816
817     UnitTestDeclaration *isUnitTestDeclaration() { return this; }
818 };
819
820 struct NewDeclaration : FuncDeclaration
821 {   Parameters *arguments;
822     int varargs;
823
824     NewDeclaration(Loc loc, Loc endloc, Parameters *arguments, int varargs);
825     Dsymbol *syntaxCopy(Dsymbol *);
826     void semantic(Scope *sc);
827     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
828     const char *kind();
829     int isVirtual();
830     int addPreInvariant();
831     int addPostInvariant();
832
833     NewDeclaration *isNewDeclaration() { return this; }
834 };
835
836
837 struct DeleteDeclaration : FuncDeclaration
838 {   Parameters *arguments;
839
840     DeleteDeclaration(Loc loc, Loc endloc, Parameters *arguments);
841     Dsymbol *syntaxCopy(Dsymbol *);
842     void semantic(Scope *sc);
843     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
844     const char *kind();
845     int isDelete();
846     int isVirtual();
847     int addPreInvariant();
848     int addPostInvariant();
849 #ifdef _DH
850     DeleteDeclaration *isDeleteDeclaration() { return this; }
851 #endif
852 };
853
854 #endif /* DMD_DECLARATION_H */
Note: See TracBrowser for help on using the browser.