comparison dmd/declaration.h @ 336:aaade6ded589 trunk

[svn r357] Merged DMD 1.033
author lindquist
date Sat, 12 Jul 2008 19:38:31 +0200
parents 2b72433d5c8c
children d8234836b40f
comparison
equal deleted inserted replaced
335:17b844102023 336:aaade6ded589
71 STCmanifest = 0x800000, // manifest constant 71 STCmanifest = 0x800000, // manifest constant
72 STCnodtor = 0x1000000, // don't run destructor 72 STCnodtor = 0x1000000, // don't run destructor
73 STCnothrow = 0x2000000, // never throws exceptions 73 STCnothrow = 0x2000000, // never throws exceptions
74 STCpure = 0x4000000, // pure function 74 STCpure = 0x4000000, // pure function
75 STCtls = 0x8000000, // thread local 75 STCtls = 0x8000000, // thread local
76 STCalias = 0x10000000, // alias parameter
76 }; 77 };
77 78
78 struct Match 79 struct Match
79 { 80 {
80 int count; // number of matches found 81 int count; // number of matches found
99 enum PROT protection; 100 enum PROT protection;
100 enum LINK linkage; 101 enum LINK linkage;
101 102
102 Declaration(Identifier *id); 103 Declaration(Identifier *id);
103 void semantic(Scope *sc); 104 void semantic(Scope *sc);
104 char *kind(); 105 const char *kind();
105 unsigned size(Loc loc); 106 unsigned size(Loc loc);
106 void checkModify(Loc loc, Scope *sc, Type *t); 107 void checkModify(Loc loc, Scope *sc, Type *t);
107 108
108 void emitComment(Scope *sc); 109 void emitComment(Scope *sc);
109 void toDocBuffer(OutBuffer *buf); 110 void toDocBuffer(OutBuffer *buf);
148 149
149 TypeTuple *tupletype; // !=NULL if this is a type tuple 150 TypeTuple *tupletype; // !=NULL if this is a type tuple
150 151
151 TupleDeclaration(Loc loc, Identifier *ident, Objects *objects); 152 TupleDeclaration(Loc loc, Identifier *ident, Objects *objects);
152 Dsymbol *syntaxCopy(Dsymbol *); 153 Dsymbol *syntaxCopy(Dsymbol *);
153 char *kind(); 154 const char *kind();
154 Type *getType(); 155 Type *getType();
155 int needThis(); 156 int needThis();
156 157
157 TupleDeclaration *isTupleDeclaration() { return this; } 158 TupleDeclaration *isTupleDeclaration() { return this; }
158 }; 159 };
172 TypedefDeclaration(Loc loc, Identifier *ident, Type *basetype, Initializer *init); 173 TypedefDeclaration(Loc loc, Identifier *ident, Type *basetype, Initializer *init);
173 Dsymbol *syntaxCopy(Dsymbol *); 174 Dsymbol *syntaxCopy(Dsymbol *);
174 void semantic(Scope *sc); 175 void semantic(Scope *sc);
175 void semantic2(Scope *sc); 176 void semantic2(Scope *sc);
176 char *mangle(); 177 char *mangle();
177 char *kind(); 178 const char *kind();
178 Type *getType(); 179 Type *getType();
179 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 180 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
180 #ifdef _DH 181 #ifdef _DH
181 Type *htype; 182 Type *htype;
182 Type *hbasetype; 183 Type *hbasetype;
183 #endif 184 #endif
184 185
185 void toDocBuffer(OutBuffer *buf); 186 void toDocBuffer(OutBuffer *buf);
186 187
187 void toObjFile(); // compile to .obj file 188 void toObjFile(int multiobj); // compile to .obj file
188 void toDebug(); 189 void toDebug();
189 int cvMember(unsigned char *p); 190 int cvMember(unsigned char *p);
190 191
191 TypedefDeclaration *isTypedefDeclaration() { return this; } 192 TypedefDeclaration *isTypedefDeclaration() { return this; }
192 193
205 AliasDeclaration(Loc loc, Identifier *ident, Type *type); 206 AliasDeclaration(Loc loc, Identifier *ident, Type *type);
206 AliasDeclaration(Loc loc, Identifier *ident, Dsymbol *s); 207 AliasDeclaration(Loc loc, Identifier *ident, Dsymbol *s);
207 Dsymbol *syntaxCopy(Dsymbol *); 208 Dsymbol *syntaxCopy(Dsymbol *);
208 void semantic(Scope *sc); 209 void semantic(Scope *sc);
209 int overloadInsert(Dsymbol *s); 210 int overloadInsert(Dsymbol *s);
210 char *kind(); 211 const char *kind();
211 Type *getType(); 212 Type *getType();
212 Dsymbol *toAlias(); 213 Dsymbol *toAlias();
213 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 214 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
214 #ifdef _DH 215 #ifdef _DH
215 Type *htype; 216 Type *htype;
240 241
241 VarDeclaration(Loc loc, Type *t, Identifier *id, Initializer *init); 242 VarDeclaration(Loc loc, Type *t, Identifier *id, Initializer *init);
242 Dsymbol *syntaxCopy(Dsymbol *); 243 Dsymbol *syntaxCopy(Dsymbol *);
243 void semantic(Scope *sc); 244 void semantic(Scope *sc);
244 void semantic2(Scope *sc); 245 void semantic2(Scope *sc);
245 char *kind(); 246 const char *kind();
246 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 247 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
247 #ifdef _DH 248 #ifdef _DH
248 Type *htype; 249 Type *htype;
249 Initializer *hinit; 250 Initializer *hinit;
250 #endif 251 #endif
257 void checkCtorConstInit(); 258 void checkCtorConstInit();
258 void checkNestedReference(Scope *sc, Loc loc); 259 void checkNestedReference(Scope *sc, Loc loc);
259 Dsymbol *toAlias(); 260 Dsymbol *toAlias();
260 261
261 Symbol *toSymbol(); 262 Symbol *toSymbol();
262 void toObjFile(); // compile to .obj file 263 void toObjFile(int multiobj); // compile to .obj file
263 int cvMember(unsigned char *p); 264 int cvMember(unsigned char *p);
264 265
265 // Eliminate need for dynamic_cast 266 // Eliminate need for dynamic_cast
266 VarDeclaration *isVarDeclaration() { return (VarDeclaration *)this; } 267 VarDeclaration *isVarDeclaration() { return (VarDeclaration *)this; }
267 268
323 void semantic(Scope *sc); 324 void semantic(Scope *sc);
324 325
325 void emitComment(Scope *sc); 326 void emitComment(Scope *sc);
326 327
327 Symbol *toSymbol(); 328 Symbol *toSymbol();
328 void toObjFile(); // compile to .obj file 329 void toObjFile(int multiobj); // compile to .obj file
329 virtual void toDt(dt_t **pdt); 330 virtual void toDt(dt_t **pdt);
330 331
331 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return this; } 332 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return this; }
332 333
333 // LLVMDC 334 // LLVMDC
464 465
465 // LLVMDC 466 // LLVMDC
466 void llvmDeclare(); 467 void llvmDeclare();
467 void llvmDefine(); 468 void llvmDefine();
468 }; 469 };
470
471 #if DMDV2
472 struct TypeInfoConstDeclaration : TypeInfoDeclaration
473 {
474 TypeInfoConstDeclaration(Type *tinfo);
475
476 void toDt(dt_t **pdt);
477
478 // LLVMDC
479 void llvmDeclare();
480 void llvmDefine();
481 };
482
483 struct TypeInfoInvariantDeclaration : TypeInfoDeclaration
484 {
485 TypeInfoInvariantDeclaration(Type *tinfo);
486
487 void toDt(dt_t **pdt);
488
489 // LLVMDC
490 void llvmDeclare();
491 void llvmDefine();
492 };
493 #endif
494
495 /**************************************************************/
469 496
470 struct ThisDeclaration : VarDeclaration 497 struct ThisDeclaration : VarDeclaration
471 { 498 {
472 ThisDeclaration(Type *t); 499 ThisDeclaration(Type *t);
473 Dsymbol *syntaxCopy(Dsymbol *); 500 Dsymbol *syntaxCopy(Dsymbol *);
479 ILSno, // cannot inline 506 ILSno, // cannot inline
480 ILSyes, // can inline 507 ILSyes, // can inline
481 }; 508 };
482 509
483 /**************************************************************/ 510 /**************************************************************/
484 511 #if DMDV2
485 #if V2
486 512
487 enum BUILTIN 513 enum BUILTIN
488 { 514 {
489 BUILTINunknown = -1, // not known if this is a builtin 515 BUILTINunknown = -1, // not known if this is a builtin
490 BUILTINnot, // this is not a builtin 516 BUILTINnot, // this is not a builtin
546 // Support for NRVO (named return value optimization) 572 // Support for NRVO (named return value optimization)
547 int nrvo_can; // !=0 means we can do it 573 int nrvo_can; // !=0 means we can do it
548 VarDeclaration *nrvo_var; // variable to replace with shidden 574 VarDeclaration *nrvo_var; // variable to replace with shidden
549 Symbol *shidden; // hidden pointer passed to function 575 Symbol *shidden; // hidden pointer passed to function
550 576
551 #if V2 577 #if DMDV2
552 enum BUILTIN builtin; // set if this is a known, builtin 578 enum BUILTIN builtin; // set if this is a known, builtin
553 // function we can evaluate at compile 579 // function we can evaluate at compile
554 // time 580 // time
555 581
556 int tookAddressOf; // set if someone took the address of 582 int tookAddressOf; // set if someone took the address of
595 virtual int addPostInvariant(); 621 virtual int addPostInvariant();
596 Expression *interpret(InterState *istate, Expressions *arguments); 622 Expression *interpret(InterState *istate, Expressions *arguments);
597 void inlineScan(); 623 void inlineScan();
598 int canInline(int hasthis, int hdrscan = 0); 624 int canInline(int hasthis, int hdrscan = 0);
599 Expression *doInline(InlineScanState *iss, Expression *ethis, Array *arguments); 625 Expression *doInline(InlineScanState *iss, Expression *ethis, Array *arguments);
600 char *kind(); 626 const char *kind();
601 void toDocBuffer(OutBuffer *buf); 627 void toDocBuffer(OutBuffer *buf);
602 628
603 static FuncDeclaration *genCfunc(Type *treturn, char *name); 629 static FuncDeclaration *genCfunc(Type *treturn, char *name);
604 static FuncDeclaration *genCfunc(Type *treturn, Identifier *id); 630 static FuncDeclaration *genCfunc(Type *treturn, Identifier *id);
605 631
606 Symbol *toSymbol(); 632 Symbol *toSymbol();
607 Symbol *toThunkSymbol(int offset); // thunk version 633 Symbol *toThunkSymbol(int offset); // thunk version
608 void toObjFile(); // compile to .obj file 634 void toObjFile(int multiobj); // compile to .obj file
609 int cvMember(unsigned char *p); 635 int cvMember(unsigned char *p);
610 636
611 FuncDeclaration *isFuncDeclaration() { return this; } 637 FuncDeclaration *isFuncDeclaration() { return this; }
612 638
613 // llvmdc stuff 639 // llvmdc stuff
625 FuncDeclaration *funcalias; 651 FuncDeclaration *funcalias;
626 652
627 FuncAliasDeclaration(FuncDeclaration *funcalias); 653 FuncAliasDeclaration(FuncDeclaration *funcalias);
628 654
629 FuncAliasDeclaration *isFuncAliasDeclaration() { return this; } 655 FuncAliasDeclaration *isFuncAliasDeclaration() { return this; }
630 char *kind(); 656 const char *kind();
631 Symbol *toSymbol(); 657 Symbol *toSymbol();
632 }; 658 };
633 659
634 struct FuncLiteralDeclaration : FuncDeclaration 660 struct FuncLiteralDeclaration : FuncDeclaration
635 { 661 {
638 FuncLiteralDeclaration(Loc loc, Loc endloc, Type *type, enum TOK tok, 664 FuncLiteralDeclaration(Loc loc, Loc endloc, Type *type, enum TOK tok,
639 ForeachStatement *fes); 665 ForeachStatement *fes);
640 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 666 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
641 Dsymbol *syntaxCopy(Dsymbol *); 667 Dsymbol *syntaxCopy(Dsymbol *);
642 int isNested(); 668 int isNested();
669 int isVirtual();
643 670
644 FuncLiteralDeclaration *isFuncLiteralDeclaration() { return this; } 671 FuncLiteralDeclaration *isFuncLiteralDeclaration() { return this; }
645 char *kind(); 672 const char *kind();
646 }; 673 };
647 674
648 struct CtorDeclaration : FuncDeclaration 675 struct CtorDeclaration : FuncDeclaration
649 { Arguments *arguments; 676 { Arguments *arguments;
650 int varargs; 677 int varargs;
651 678
652 CtorDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); 679 CtorDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs);
653 Dsymbol *syntaxCopy(Dsymbol *); 680 Dsymbol *syntaxCopy(Dsymbol *);
654 void semantic(Scope *sc); 681 void semantic(Scope *sc);
655 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 682 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
656 char *kind(); 683 const char *kind();
657 char *toChars(); 684 char *toChars();
658 int isVirtual(); 685 int isVirtual();
659 int addPreInvariant(); 686 int addPreInvariant();
660 int addPostInvariant(); 687 int addPostInvariant();
661 void toDocBuffer(OutBuffer *buf); 688 void toDocBuffer(OutBuffer *buf);
662 689
663 CtorDeclaration *isCtorDeclaration() { return this; } 690 CtorDeclaration *isCtorDeclaration() { return this; }
664 }; 691 };
665 692
666 struct DtorDeclaration : FuncDeclaration 693 #if DMDV2
667 { 694 struct PostBlitDeclaration : FuncDeclaration
668 DtorDeclaration(Loc loc, Loc endloc); 695 {
669 DtorDeclaration(Loc loc, Loc endloc, Identifier *id); 696 PostBlitDeclaration(Loc loc, Loc endloc);
697 PostBlitDeclaration(Loc loc, Loc endloc, Identifier *id);
670 Dsymbol *syntaxCopy(Dsymbol *); 698 Dsymbol *syntaxCopy(Dsymbol *);
671 void semantic(Scope *sc); 699 void semantic(Scope *sc);
672 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 700 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
673 int isVirtual(); 701 int isVirtual();
674 int addPreInvariant(); 702 int addPreInvariant();
675 int addPostInvariant(); 703 int addPostInvariant();
676 int overloadInsert(Dsymbol *s); 704 int overloadInsert(Dsymbol *s);
677 void emitComment(Scope *sc); 705 void emitComment(Scope *sc);
678 706
707 PostBlitDeclaration *isPostBlitDeclaration() { return this; }
708 };
709 #endif
710
711 struct DtorDeclaration : FuncDeclaration
712 {
713 DtorDeclaration(Loc loc, Loc endloc);
714 DtorDeclaration(Loc loc, Loc endloc, Identifier *id);
715 Dsymbol *syntaxCopy(Dsymbol *);
716 void semantic(Scope *sc);
717 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
718 int isVirtual();
719 int addPreInvariant();
720 int addPostInvariant();
721 int overloadInsert(Dsymbol *s);
722 void emitComment(Scope *sc);
723
679 DtorDeclaration *isDtorDeclaration() { return this; } 724 DtorDeclaration *isDtorDeclaration() { return this; }
680 }; 725 };
681 726
682 struct StaticCtorDeclaration : FuncDeclaration 727 struct StaticCtorDeclaration : FuncDeclaration
683 { 728 {
694 739
695 StaticCtorDeclaration *isStaticCtorDeclaration() { return this; } 740 StaticCtorDeclaration *isStaticCtorDeclaration() { return this; }
696 }; 741 };
697 742
698 struct StaticDtorDeclaration : FuncDeclaration 743 struct StaticDtorDeclaration : FuncDeclaration
699 { 744 { VarDeclaration *vgate; // 'gate' variable
745
700 StaticDtorDeclaration(Loc loc, Loc endloc); 746 StaticDtorDeclaration(Loc loc, Loc endloc);
701 Dsymbol *syntaxCopy(Dsymbol *); 747 Dsymbol *syntaxCopy(Dsymbol *);
702 void semantic(Scope *sc); 748 void semantic(Scope *sc);
703 AggregateDeclaration *isThis(); 749 AggregateDeclaration *isThis();
704 int isStaticDestructor(); 750 int isStaticDestructor();
746 792
747 NewDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); 793 NewDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs);
748 Dsymbol *syntaxCopy(Dsymbol *); 794 Dsymbol *syntaxCopy(Dsymbol *);
749 void semantic(Scope *sc); 795 void semantic(Scope *sc);
750 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 796 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
751 char *kind(); 797 const char *kind();
752 int isVirtual(); 798 int isVirtual();
753 int addPreInvariant(); 799 int addPreInvariant();
754 int addPostInvariant(); 800 int addPostInvariant();
755 801
756 NewDeclaration *isNewDeclaration() { return this; } 802 NewDeclaration *isNewDeclaration() { return this; }
762 808
763 DeleteDeclaration(Loc loc, Loc endloc, Arguments *arguments); 809 DeleteDeclaration(Loc loc, Loc endloc, Arguments *arguments);
764 Dsymbol *syntaxCopy(Dsymbol *); 810 Dsymbol *syntaxCopy(Dsymbol *);
765 void semantic(Scope *sc); 811 void semantic(Scope *sc);
766 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 812 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
767 char *kind(); 813 const char *kind();
768 int isDelete(); 814 int isDelete();
769 int isVirtual(); 815 int isVirtual();
770 int addPreInvariant(); 816 int addPreInvariant();
771 int addPostInvariant(); 817 int addPostInvariant();
772 #ifdef _DH 818 #ifdef _DH