comparison gen/typinf.cpp @ 137:ce7b81fb957f trunk

[svn r141] fixed more problems with classinfo moved more IR state out of the AST classes
author lindquist
date Fri, 18 Jan 2008 16:42:16 +0100
parents 0e28624814e8
children 7f92f477ff53
comparison
equal deleted inserted replaced
136:0e28624814e8 137:ce7b81fb957f
370 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); 370 const llvm::StructType* stype = isaStruct(base->type->llvmType->get());
371 Logger::cout() << "got stype: " << *stype << '\n'; 371 Logger::cout() << "got stype: " << *stype << '\n';
372 372
373 // vtbl 373 // vtbl
374 std::vector<llvm::Constant*> sinits; 374 std::vector<llvm::Constant*> sinits;
375 sinits.push_back(base->llvmVtbl); 375 sinits.push_back(base->irStruct->vtbl);
376 376
377 // monitor 377 // monitor
378 sinits.push_back(getNullPtr(getPtrToType(llvm::Type::Int8Ty))); 378 sinits.push_back(getNullPtr(getPtrToType(llvm::Type::Int8Ty)));
379 379
380 assert(tinfo->ty == Ttypedef); 380 assert(tinfo->ty == Ttypedef);
455 455
456 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); 456 const llvm::StructType* stype = isaStruct(base->type->llvmType->get());
457 457
458 // vtbl 458 // vtbl
459 std::vector<llvm::Constant*> sinits; 459 std::vector<llvm::Constant*> sinits;
460 sinits.push_back(base->llvmVtbl); 460 sinits.push_back(base->irStruct->vtbl);
461 461
462 // monitor 462 // monitor
463 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); 463 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
464 464
465 assert(tinfo->ty == Tenum); 465 assert(tinfo->ty == Tenum);
534 534
535 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); 535 const llvm::StructType* stype = isaStruct(base->type->llvmType->get());
536 536
537 // vtbl 537 // vtbl
538 std::vector<llvm::Constant*> sinits; 538 std::vector<llvm::Constant*> sinits;
539 sinits.push_back(base->llvmVtbl); 539 sinits.push_back(base->irStruct->vtbl);
540 540
541 // monitor 541 // monitor
542 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); 542 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
543 543
544 // TypeInfo base 544 // TypeInfo base
645 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); 645 const llvm::StructType* stype = isaStruct(base->type->llvmType->get());
646 646
647 // initializer vector 647 // initializer vector
648 std::vector<llvm::Constant*> sinits; 648 std::vector<llvm::Constant*> sinits;
649 // first is always the vtable 649 // first is always the vtable
650 sinits.push_back(base->llvmVtbl); 650 sinits.push_back(base->irStruct->vtbl);
651 651
652 // monitor 652 // monitor
653 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); 653 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
654 654
655 // value typeinfo 655 // value typeinfo
708 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); 708 const llvm::StructType* stype = isaStruct(base->type->llvmType->get());
709 709
710 // initializer vector 710 // initializer vector
711 std::vector<llvm::Constant*> sinits; 711 std::vector<llvm::Constant*> sinits;
712 // first is always the vtable 712 // first is always the vtable
713 sinits.push_back(base->llvmVtbl); 713 sinits.push_back(base->irStruct->vtbl);
714 714
715 // monitor 715 // monitor
716 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); 716 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
717 717
718 // get type 718 // get type
843 843
844 const llvm::StructType* stype = isaStruct(((TypeClass*)base->type)->llvmType->get()); 844 const llvm::StructType* stype = isaStruct(((TypeClass*)base->type)->llvmType->get());
845 845
846 // vtbl 846 // vtbl
847 std::vector<llvm::Constant*> sinits; 847 std::vector<llvm::Constant*> sinits;
848 sinits.push_back(base->llvmVtbl); 848 sinits.push_back(base->irStruct->vtbl);
849 849
850 // monitor 850 // monitor
851 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); 851 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
852 852
853 // char[] name 853 // char[] name
863 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); 863 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt)));
864 } 864 }
865 else 865 else
866 { 866 {
867 size_t cisize = getTypeStoreSize(tc->llvmType->get()); 867 size_t cisize = getTypeStoreSize(tc->llvmType->get());
868 llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(sd->llvmInit, initpt); 868 llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(sd->irStruct->init, initpt);
869 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast)); 869 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast));
870 } 870 }
871 871
872 // toX functions ground work 872 // toX functions ground work
873 FuncDeclaration *fd; 873 FuncDeclaration *fd;
1042 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); 1042 const llvm::StructType* stype = isaStruct(base->type->llvmType->get());
1043 1043
1044 // initializer vector 1044 // initializer vector
1045 std::vector<llvm::Constant*> sinits; 1045 std::vector<llvm::Constant*> sinits;
1046 // first is always the vtable 1046 // first is always the vtable
1047 sinits.push_back(base->llvmVtbl); 1047 sinits.push_back(base->irStruct->vtbl);
1048 1048
1049 // monitor 1049 // monitor
1050 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); 1050 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
1051 1051
1052 // get classinfo 1052 // get classinfo
1053 assert(tinfo->ty == Tclass); 1053 assert(tinfo->ty == Tclass);
1054 TypeClass *tc = (TypeClass *)tinfo; 1054 TypeClass *tc = (TypeClass *)tinfo;
1055 assert(tc->sym->llvmClass); 1055 assert(tc->sym->irStruct->classInfo);
1056 sinits.push_back(tc->sym->llvmClass); 1056 sinits.push_back(tc->sym->irStruct->classInfo);
1057 1057
1058 // create the symbol 1058 // create the symbol
1059 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); 1059 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
1060 isaGlobalVar(irGlobal->value)->setInitializer(tiInit); 1060 isaGlobalVar(irGlobal->value)->setInitializer(tiInit);
1061 } 1061 }
1098 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); 1098 const llvm::StructType* stype = isaStruct(base->type->llvmType->get());
1099 1099
1100 // initializer vector 1100 // initializer vector
1101 std::vector<llvm::Constant*> sinits; 1101 std::vector<llvm::Constant*> sinits;
1102 // first is always the vtable 1102 // first is always the vtable
1103 sinits.push_back(base->llvmVtbl); 1103 sinits.push_back(base->irStruct->vtbl);
1104 1104
1105 // monitor 1105 // monitor
1106 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); 1106 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
1107 1107
1108 // get classinfo 1108 // get classinfo
1109 assert(tinfo->ty == Tclass); 1109 assert(tinfo->ty == Tclass);
1110 TypeClass *tc = (TypeClass *)tinfo; 1110 TypeClass *tc = (TypeClass *)tinfo;
1111 assert(tc->sym->llvmClass); 1111 assert(tc->sym->irStruct->classInfo);
1112 sinits.push_back(tc->sym->llvmClass); 1112 sinits.push_back(tc->sym->irStruct->classInfo);
1113 1113
1114 // create the symbol 1114 // create the symbol
1115 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); 1115 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
1116 isaGlobalVar(irGlobal->value)->setInitializer(tiInit); 1116 isaGlobalVar(irGlobal->value)->setInitializer(tiInit);
1117 } 1117 }
1154 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); 1154 const llvm::StructType* stype = isaStruct(base->type->llvmType->get());
1155 1155
1156 // initializer vector 1156 // initializer vector
1157 std::vector<llvm::Constant*> sinits; 1157 std::vector<llvm::Constant*> sinits;
1158 // first is always the vtable 1158 // first is always the vtable
1159 sinits.push_back(base->llvmVtbl); 1159 sinits.push_back(base->irStruct->vtbl);
1160 1160
1161 // monitor 1161 // monitor
1162 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); 1162 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
1163 1163
1164 // create elements array 1164 // create elements array