comparison gen/typinf.cpp @ 1146:1860414bf3b7

* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h. * Added #if IN_DMD versioning around DMD backend specific code in the D1 frontend, D2 is currently broken. * All part of a greater cleanup scheme.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Thu, 26 Mar 2009 20:45:53 +0100
parents f0b6549055ab
children dbe4af57b240
comparison
equal deleted inserted replaced
1145:40caa8207b3e 1146:1860414bf3b7
350 tid->llvmDefine(); 350 tid->llvmDefine();
351 } 351 }
352 352
353 /* ========================================================================= */ 353 /* ========================================================================= */
354 354
355 void TypeInfoDeclaration::toDt(dt_t **pdt)
356 {
357 assert(0 && "TypeInfoDeclaration::toDt");
358 }
359
360 void TypeInfoDeclaration::llvmDeclare() 355 void TypeInfoDeclaration::llvmDeclare()
361 { 356 {
362 assert(0 && "TypeInfoDeclaration::llvmDeclare"); 357 assert(0 && "TypeInfoDeclaration::llvmDeclare");
363 } 358 }
364 359
434 // refine global type 429 // refine global type
435 llvm::cast<llvm::OpaqueType>(ir.irGlobal->type.get())->refineAbstractTypeTo(tiInit->getType()); 430 llvm::cast<llvm::OpaqueType>(ir.irGlobal->type.get())->refineAbstractTypeTo(tiInit->getType());
436 431
437 // set the initializer 432 // set the initializer
438 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit); 433 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
439 }
440
441 void TypeInfoTypedefDeclaration::toDt(dt_t **pdt)
442 {
443 assert(0);
444 } 434 }
445 435
446 /* ========================================================================= */ 436 /* ========================================================================= */
447 437
448 void TypeInfoEnumDeclaration::llvmDeclare() 438 void TypeInfoEnumDeclaration::llvmDeclare()
514 504
515 // set the initializer 505 // set the initializer
516 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit); 506 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
517 } 507 }
518 508
519 void TypeInfoEnumDeclaration::toDt(dt_t **pdt)
520 {
521 assert(0);
522 }
523
524 /* ========================================================================= */ 509 /* ========================================================================= */
525 510
526 static void LLVM_D_Declare_TypeInfoBase(TypeInfoDeclaration* tid, ClassDeclaration* cd) 511 static void LLVM_D_Declare_TypeInfoBase(TypeInfoDeclaration* tid, ClassDeclaration* cd)
527 { 512 {
528 ClassDeclaration* base = cd; 513 ClassDeclaration* base = cd;
580 TypePointer *tc = (TypePointer *)tinfo; 565 TypePointer *tc = (TypePointer *)tinfo;
581 566
582 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfopointer); 567 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfopointer);
583 } 568 }
584 569
585 void TypeInfoPointerDeclaration::toDt(dt_t **pdt)
586 {
587 assert(0);
588 }
589
590 /* ========================================================================= */ 570 /* ========================================================================= */
591 571
592 void TypeInfoArrayDeclaration::llvmDeclare() 572 void TypeInfoArrayDeclaration::llvmDeclare()
593 { 573 {
594 Logger::println("TypeInfoArrayDeclaration::llvmDeclare() %s", toChars()); 574 Logger::println("TypeInfoArrayDeclaration::llvmDeclare() %s", toChars());
609 TypeDArray *tc = (TypeDArray *)tinfo; 589 TypeDArray *tc = (TypeDArray *)tinfo;
610 590
611 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfoarray); 591 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfoarray);
612 } 592 }
613 593
614 void TypeInfoArrayDeclaration::toDt(dt_t **pdt)
615 {
616 assert(0);
617 }
618
619 /* ========================================================================= */ 594 /* ========================================================================= */
620 595
621 void TypeInfoStaticArrayDeclaration::llvmDeclare() 596 void TypeInfoStaticArrayDeclaration::llvmDeclare()
622 { 597 {
623 Logger::println("TypeInfoStaticArrayDeclaration::toDt() %s", toChars()); 598 Logger::println("TypeInfoStaticArrayDeclaration::llvmDeclare() %s", toChars());
624 LOG_SCOPE; 599 LOG_SCOPE;
625 600
626 // init typeinfo class 601 // init typeinfo class
627 ClassDeclaration* base = Type::typeinfostaticarray; 602 ClassDeclaration* base = Type::typeinfostaticarray;
628 DtoResolveClass(base); 603 DtoResolveClass(base);
631 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module); 606 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module);
632 } 607 }
633 608
634 void TypeInfoStaticArrayDeclaration::llvmDefine() 609 void TypeInfoStaticArrayDeclaration::llvmDefine()
635 { 610 {
636 Logger::println("TypeInfoStaticArrayDeclaration::toDt() %s", toChars()); 611 Logger::println("TypeInfoStaticArrayDeclaration::llvmDefine() %s", toChars());
637 LOG_SCOPE; 612 LOG_SCOPE;
638 613
639 // init typeinfo class 614 // init typeinfo class
640 ClassDeclaration* base = Type::typeinfostaticarray; 615 ClassDeclaration* base = Type::typeinfostaticarray;
641 DtoForceConstInitDsymbol(base); 616 DtoForceConstInitDsymbol(base);
669 644
670 // set the initializer 645 // set the initializer
671 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit); 646 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
672 } 647 }
673 648
674 void TypeInfoStaticArrayDeclaration::toDt(dt_t **pdt)
675 {
676 assert(0);
677 }
678
679 /* ========================================================================= */ 649 /* ========================================================================= */
680 650
681 void TypeInfoAssociativeArrayDeclaration::llvmDeclare() 651 void TypeInfoAssociativeArrayDeclaration::llvmDeclare()
682 { 652 {
683 Logger::println("TypeInfoAssociativeArrayDeclaration::toDt() %s", toChars()); 653 Logger::println("TypeInfoAssociativeArrayDeclaration::llvmDeclare() %s", toChars());
684 LOG_SCOPE; 654 LOG_SCOPE;
685 655
686 // init typeinfo class 656 // init typeinfo class
687 ClassDeclaration* base = Type::typeinfoassociativearray; 657 ClassDeclaration* base = Type::typeinfoassociativearray;
688 DtoResolveClass(base); 658 DtoResolveClass(base);
691 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module); 661 ir.irGlobal->value = new llvm::GlobalVariable(ir.irGlobal->type.get(), true, TYPEINFO_LINKAGE_TYPE, NULL, toChars(), gIR->module);
692 } 662 }
693 663
694 void TypeInfoAssociativeArrayDeclaration::llvmDefine() 664 void TypeInfoAssociativeArrayDeclaration::llvmDefine()
695 { 665 {
696 Logger::println("TypeInfoAssociativeArrayDeclaration::toDt() %s", toChars()); 666 Logger::println("TypeInfoAssociativeArrayDeclaration::llvmDefine() %s", toChars());
697 LOG_SCOPE; 667 LOG_SCOPE;
698 668
699 // init typeinfo class 669 // init typeinfo class
700 ClassDeclaration* base = Type::typeinfoassociativearray; 670 ClassDeclaration* base = Type::typeinfoassociativearray;
701 DtoForceConstInitDsymbol(base); 671 DtoForceConstInitDsymbol(base);
728 698
729 // set the initializer 699 // set the initializer
730 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit); 700 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
731 } 701 }
732 702
733 void TypeInfoAssociativeArrayDeclaration::toDt(dt_t **pdt)
734 {
735 assert(0);
736 }
737
738 /* ========================================================================= */ 703 /* ========================================================================= */
739 704
740 void TypeInfoFunctionDeclaration::llvmDeclare() 705 void TypeInfoFunctionDeclaration::llvmDeclare()
741 { 706 {
742 Logger::println("TypeInfoFunctionDeclaration::toDt() %s", toChars()); 707 Logger::println("TypeInfoFunctionDeclaration::llvmDeclare() %s", toChars());
743 LOG_SCOPE; 708 LOG_SCOPE;
744 709
745 assert(tinfo->ty == Tfunction); 710 assert(tinfo->ty == Tfunction);
746 TypeFunction *tc = (TypeFunction *)tinfo; 711 TypeFunction *tc = (TypeFunction *)tinfo;
747 712
748 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfofunction); 713 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfofunction);
749 } 714 }
750 715
751 void TypeInfoFunctionDeclaration::llvmDefine() 716 void TypeInfoFunctionDeclaration::llvmDefine()
752 { 717 {
753 Logger::println("TypeInfoFunctionDeclaration::toDt() %s", toChars()); 718 Logger::println("TypeInfoFunctionDeclaration::llvmDefine() %s", toChars());
754 LOG_SCOPE; 719 LOG_SCOPE;
755 720
756 assert(tinfo->ty == Tfunction); 721 assert(tinfo->ty == Tfunction);
757 TypeFunction *tc = (TypeFunction *)tinfo; 722 TypeFunction *tc = (TypeFunction *)tinfo;
758 723
759 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfofunction); 724 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfofunction);
760 } 725 }
761 726
762 void TypeInfoFunctionDeclaration::toDt(dt_t **pdt)
763 {
764 assert(0);
765 }
766
767 /* ========================================================================= */ 727 /* ========================================================================= */
768 728
769 void TypeInfoDelegateDeclaration::llvmDeclare() 729 void TypeInfoDelegateDeclaration::llvmDeclare()
770 { 730 {
771 Logger::println("TypeInfoDelegateDeclaration::toDt() %s", toChars()); 731 Logger::println("TypeInfoDelegateDeclaration::llvmDeclare() %s", toChars());
772 LOG_SCOPE; 732 LOG_SCOPE;
773 733
774 assert(tinfo->ty == Tdelegate); 734 assert(tinfo->ty == Tdelegate);
775 TypeDelegate *tc = (TypeDelegate *)tinfo; 735 TypeDelegate *tc = (TypeDelegate *)tinfo;
776 736
777 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfodelegate); 737 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfodelegate);
778 } 738 }
779 739
780 void TypeInfoDelegateDeclaration::llvmDefine() 740 void TypeInfoDelegateDeclaration::llvmDefine()
781 { 741 {
782 Logger::println("TypeInfoDelegateDeclaration::toDt() %s", toChars()); 742 Logger::println("TypeInfoDelegateDeclaration::llvmDefine() %s", toChars());
783 LOG_SCOPE; 743 LOG_SCOPE;
784 744
785 assert(tinfo->ty == Tdelegate); 745 assert(tinfo->ty == Tdelegate);
786 TypeDelegate *tc = (TypeDelegate *)tinfo; 746 TypeDelegate *tc = (TypeDelegate *)tinfo;
787 747
788 LLVM_D_Define_TypeInfoBase(tc->nextOf()->nextOf(), this, Type::typeinfodelegate); 748 LLVM_D_Define_TypeInfoBase(tc->nextOf()->nextOf(), this, Type::typeinfodelegate);
789 }
790
791 void TypeInfoDelegateDeclaration::toDt(dt_t **pdt)
792 {
793 assert(0);
794 } 749 }
795 750
796 /* ========================================================================= */ 751 /* ========================================================================= */
797 752
798 void TypeInfoStructDeclaration::llvmDeclare() 753 void TypeInfoStructDeclaration::llvmDeclare()
1005 960
1006 // set the initializer 961 // set the initializer
1007 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit); 962 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
1008 } 963 }
1009 964
1010 void TypeInfoStructDeclaration::toDt(dt_t **pdt)
1011 {
1012 assert(0);
1013 }
1014
1015 /* ========================================================================= */ 965 /* ========================================================================= */
1016 966
1017 void TypeInfoClassDeclaration::llvmDeclare() 967 void TypeInfoClassDeclaration::llvmDeclare()
1018 { 968 {
1019 Logger::println("TypeInfoClassDeclaration::llvmDeclare() %s", toChars()); 969 Logger::println("TypeInfoClassDeclaration::llvmDeclare() %s", toChars());
1061 1011
1062 // set the initializer 1012 // set the initializer
1063 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit); 1013 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
1064 } 1014 }
1065 1015
1066 void TypeInfoClassDeclaration::toDt(dt_t **pdt)
1067 {
1068 assert(0);
1069 }
1070
1071 /* ========================================================================= */ 1016 /* ========================================================================= */
1072 1017
1073 void TypeInfoInterfaceDeclaration::llvmDeclare() 1018 void TypeInfoInterfaceDeclaration::llvmDeclare()
1074 { 1019 {
1075 Logger::println("TypeInfoInterfaceDeclaration::llvmDeclare() %s", toChars()); 1020 Logger::println("TypeInfoInterfaceDeclaration::llvmDeclare() %s", toChars());
1119 1064
1120 // set the initializer 1065 // set the initializer
1121 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit); 1066 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
1122 } 1067 }
1123 1068
1124 void TypeInfoInterfaceDeclaration::toDt(dt_t **pdt)
1125 {
1126 assert(0);
1127 }
1128
1129 /* ========================================================================= */ 1069 /* ========================================================================= */
1130 1070
1131 void TypeInfoTupleDeclaration::llvmDeclare() 1071 void TypeInfoTupleDeclaration::llvmDeclare()
1132 { 1072 {
1133 Logger::println("TypeInfoTupleDeclaration::llvmDeclare() %s", toChars()); 1073 Logger::println("TypeInfoTupleDeclaration::llvmDeclare() %s", toChars());
1206 1146
1207 // set the initializer 1147 // set the initializer
1208 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit); 1148 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
1209 } 1149 }
1210 1150
1211 void TypeInfoTupleDeclaration::toDt(dt_t **pdt)
1212 {
1213 assert(0);
1214 }
1215
1216 /* ========================================================================= */ 1151 /* ========================================================================= */
1217 1152
1218 #if DMDV2 1153 #if DMDV2
1219 1154
1220 void TypeInfoConstDeclaration::llvmDeclare() 1155 void TypeInfoConstDeclaration::llvmDeclare()
1221 { 1156 {
1222 Logger::println("TypeInfoConstDeclaration::toDt() %s", toChars()); 1157 Logger::println("TypeInfoConstDeclaration::llvmDeclare() %s", toChars());
1223 LOG_SCOPE; 1158 LOG_SCOPE;
1224 1159
1225 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfoconst); 1160 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfoconst);
1226 } 1161 }
1227 1162
1228 void TypeInfoConstDeclaration::llvmDefine() 1163 void TypeInfoConstDeclaration::llvmDefine()
1229 { 1164 {
1230 Logger::println("TypeInfoConstDeclaration::toDt() %s", toChars()); 1165 Logger::println("TypeInfoConstDeclaration::llvmDefine() %s", toChars());
1231 LOG_SCOPE; 1166 LOG_SCOPE;
1232 1167
1233 Type *tm = tinfo->mutableOf(); 1168 Type *tm = tinfo->mutableOf();
1234 tm = tm->merge(); 1169 tm = tm->merge();
1235 1170
1236 LLVM_D_Define_TypeInfoBase(tm, this, Type::typeinfoconst); 1171 LLVM_D_Define_TypeInfoBase(tm, this, Type::typeinfoconst);
1237 } 1172 }
1238 1173
1239 void TypeInfoConstDeclaration::toDt(dt_t **pdt)
1240 {
1241 assert(0);
1242 }
1243
1244 ///////////////////////////////////////////////////////////
1245
1246 /* ========================================================================= */ 1174 /* ========================================================================= */
1247 1175
1248 void TypeInfoInvariantDeclaration::llvmDeclare() 1176 void TypeInfoInvariantDeclaration::llvmDeclare()
1249 { 1177 {
1250 Logger::println("TypeInfoInvariantDeclaration::toDt() %s", toChars()); 1178 Logger::println("TypeInfoInvariantDeclaration::llvmDeclare() %s", toChars());
1251 LOG_SCOPE; 1179 LOG_SCOPE;
1252 1180
1253 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfoinvariant); 1181 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfoinvariant);
1254 } 1182 }
1255 1183
1256 void TypeInfoInvariantDeclaration::llvmDefine() 1184 void TypeInfoInvariantDeclaration::llvmDefine()
1257 { 1185 {
1258 Logger::println("TypeInfoInvariantDeclaration::toDt() %s", toChars()); 1186 Logger::println("TypeInfoInvariantDeclaration::llvmDefine() %s", toChars());
1259 LOG_SCOPE; 1187 LOG_SCOPE;
1260 1188
1261 Type *tm = tinfo->mutableOf(); 1189 Type *tm = tinfo->mutableOf();
1262 tm = tm->merge(); 1190 tm = tm->merge();
1263 1191
1264 LLVM_D_Define_TypeInfoBase(tm, this, Type::typeinfoinvariant); 1192 LLVM_D_Define_TypeInfoBase(tm, this, Type::typeinfoinvariant);
1265 } 1193 }
1266 1194
1267 void TypeInfoInvariantDeclaration::toDt(dt_t **pdt)
1268 {
1269 assert(0);
1270 }
1271
1272 #endif 1195 #endif