Mercurial > projects > ldc
comparison gen/typinf.cpp @ 1228:79758fd2f48a
Added Doxygen file.
Completely seperated type and symbol generation. Should fix a lot of bugs, but is not yet 100% complete.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Wed, 15 Apr 2009 20:06:25 +0200 |
parents | 19d4ded7204a |
children | 465a77c904d4 |
comparison
equal
deleted
inserted
replaced
1215:08f87d8cd101 | 1228:79758fd2f48a |
---|---|
251 #endif | 251 #endif |
252 } | 252 } |
253 | 253 |
254 /* ========================================================================= */ | 254 /* ========================================================================= */ |
255 | 255 |
256 /*************************************** | |
257 * Create a static array of TypeInfo references | |
258 * corresponding to an array of Expression's. | |
259 * Used to supply hidden _arguments[] value for variadic D functions. | |
260 */ | |
261 | |
262 Expression *createTypeInfoArray(Scope *sc, Expression *exps[], int dim) | |
263 { | |
264 assert(0); // done elsewhere in LDC | |
265 return NULL; | |
266 } | |
267 | |
268 /* ========================================================================= */ | |
269 | |
270 ////////////////////////////////////////////////////////////////////////////// | 256 ////////////////////////////////////////////////////////////////////////////// |
271 // MAGIC PLACE | 257 // MAGIC PLACE |
272 ////////////////////////////////////////////////////////////////////////////// | 258 ////////////////////////////////////////////////////////////////////////////// |
273 | 259 |
274 void DtoResolveTypeInfo(TypeInfoDeclaration* tid); | 260 void DtoResolveTypeInfo(TypeInfoDeclaration* tid); |
374 ClassDeclaration* base = Type::typeinfotypedef; | 360 ClassDeclaration* base = Type::typeinfotypedef; |
375 base->codegen(Type::sir); | 361 base->codegen(Type::sir); |
376 | 362 |
377 // vtbl | 363 // vtbl |
378 std::vector<LLConstant*> sinits; | 364 std::vector<LLConstant*> sinits; |
379 sinits.push_back(base->ir.irStruct->vtbl); | 365 sinits.push_back(base->ir.irStruct->getVtblSymbol()); |
380 | 366 |
381 // monitor | 367 // monitor |
382 sinits.push_back(getNullPtr(getPtrToType(LLType::Int8Ty))); | 368 sinits.push_back(getNullPtr(getPtrToType(LLType::Int8Ty))); |
383 | 369 |
384 assert(tinfo->ty == Ttypedef); | 370 assert(tinfo->ty == Ttypedef); |
431 ClassDeclaration* base = Type::typeinfoenum; | 417 ClassDeclaration* base = Type::typeinfoenum; |
432 base->codegen(Type::sir); | 418 base->codegen(Type::sir); |
433 | 419 |
434 // vtbl | 420 // vtbl |
435 std::vector<LLConstant*> sinits; | 421 std::vector<LLConstant*> sinits; |
436 sinits.push_back(base->ir.irStruct->vtbl); | 422 sinits.push_back(base->ir.irStruct->getVtblSymbol()); |
437 | 423 |
438 // monitor | 424 // monitor |
439 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); | 425 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
440 | 426 |
441 assert(tinfo->ty == Tenum); | 427 assert(tinfo->ty == Tenum); |
489 ClassDeclaration* base = cd; | 475 ClassDeclaration* base = cd; |
490 base->codegen(Type::sir); | 476 base->codegen(Type::sir); |
491 | 477 |
492 // vtbl | 478 // vtbl |
493 std::vector<LLConstant*> sinits; | 479 std::vector<LLConstant*> sinits; |
494 sinits.push_back(base->ir.irStruct->vtbl); | 480 sinits.push_back(base->ir.irStruct->getVtblSymbol()); |
495 | 481 |
496 // monitor | 482 // monitor |
497 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); | 483 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
498 | 484 |
499 // TypeInfo base | 485 // TypeInfo base |
551 const LLStructType* stype = isaStruct(base->type->ir.type->get()); | 537 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
552 | 538 |
553 // initializer vector | 539 // initializer vector |
554 std::vector<LLConstant*> sinits; | 540 std::vector<LLConstant*> sinits; |
555 // first is always the vtable | 541 // first is always the vtable |
556 sinits.push_back(base->ir.irStruct->vtbl); | 542 sinits.push_back(base->ir.irStruct->getVtblSymbol()); |
557 | 543 |
558 // monitor | 544 // monitor |
559 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); | 545 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
560 | 546 |
561 // value typeinfo | 547 // value typeinfo |
590 base->codegen(Type::sir); | 576 base->codegen(Type::sir); |
591 | 577 |
592 // initializer vector | 578 // initializer vector |
593 std::vector<LLConstant*> sinits; | 579 std::vector<LLConstant*> sinits; |
594 // first is always the vtable | 580 // first is always the vtable |
595 sinits.push_back(base->ir.irStruct->vtbl); | 581 sinits.push_back(base->ir.irStruct->getVtblSymbol()); |
596 | 582 |
597 // monitor | 583 // monitor |
598 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); | 584 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
599 | 585 |
600 // get type | 586 // get type |
662 | 648 |
663 const LLStructType* stype = isaStruct(base->type->ir.type->get()); | 649 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
664 | 650 |
665 // vtbl | 651 // vtbl |
666 std::vector<LLConstant*> sinits; | 652 std::vector<LLConstant*> sinits; |
667 sinits.push_back(base->ir.irStruct->vtbl); | 653 sinits.push_back(base->ir.irStruct->getVtblSymbol()); |
668 | 654 |
669 // monitor | 655 // monitor |
670 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); | 656 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
671 | 657 |
672 // char[] name | 658 // char[] name |
685 } | 671 } |
686 else | 672 else |
687 #endif | 673 #endif |
688 { | 674 { |
689 size_t cisize = getTypeStoreSize(tc->ir.type->get()); | 675 size_t cisize = getTypeStoreSize(tc->ir.type->get()); |
690 LLConstant* cicast = llvm::ConstantExpr::getBitCast(sd->ir.irStruct->init, initpt); | 676 LLConstant* cicast = llvm::ConstantExpr::getBitCast(sd->ir.irStruct->getInitSymbol(), initpt); |
691 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast)); | 677 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast)); |
692 } | 678 } |
693 | 679 |
694 // toX functions ground work | 680 // toX functions ground work |
695 FuncDeclaration *fd; | 681 FuncDeclaration *fd; |
855 base->codegen(Type::sir); | 841 base->codegen(Type::sir); |
856 | 842 |
857 // initializer vector | 843 // initializer vector |
858 std::vector<LLConstant*> sinits; | 844 std::vector<LLConstant*> sinits; |
859 // first is always the vtable | 845 // first is always the vtable |
860 sinits.push_back(base->ir.irStruct->vtbl); | 846 sinits.push_back(base->ir.irStruct->getVtblSymbol()); |
861 | 847 |
862 // monitor | 848 // monitor |
863 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); | 849 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
864 | 850 |
865 // get classinfo | 851 // get classinfo |
866 assert(tinfo->ty == Tclass); | 852 assert(tinfo->ty == Tclass); |
867 TypeClass *tc = (TypeClass *)tinfo; | 853 TypeClass *tc = (TypeClass *)tinfo; |
868 tc->sym->codegen(Type::sir);; | 854 |
869 assert(tc->sym->ir.irStruct->classInfo); | 855 tc->sym->codegen(Type::sir); |
870 sinits.push_back(tc->sym->ir.irStruct->classInfo); | 856 |
857 sinits.push_back(tc->sym->ir.irStruct->getClassInfoSymbol()); | |
871 | 858 |
872 // create the inititalizer | 859 // create the inititalizer |
873 LLConstant* tiInit = llvm::ConstantStruct::get(sinits); | 860 LLConstant* tiInit = llvm::ConstantStruct::get(sinits); |
874 | 861 |
875 // refine global type | 862 // refine global type |
895 const LLStructType* stype = isaStruct(base->type->ir.type->get()); | 882 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
896 | 883 |
897 // initializer vector | 884 // initializer vector |
898 std::vector<LLConstant*> sinits; | 885 std::vector<LLConstant*> sinits; |
899 // first is always the vtable | 886 // first is always the vtable |
900 sinits.push_back(base->ir.irStruct->vtbl); | 887 sinits.push_back(base->ir.irStruct->getVtblSymbol()); |
901 | 888 |
902 // monitor | 889 // monitor |
903 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); | 890 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
904 | 891 |
905 // get classinfo | 892 // get classinfo |
906 assert(tinfo->ty == Tclass); | 893 assert(tinfo->ty == Tclass); |
907 TypeClass *tc = (TypeClass *)tinfo; | 894 TypeClass *tc = (TypeClass *)tinfo; |
908 assert(tc->sym->ir.irStruct->classInfo); | 895 |
909 sinits.push_back(tc->sym->ir.irStruct->classInfo); | 896 sinits.push_back(tc->sym->ir.irStruct->getClassInfoSymbol()); |
910 | 897 |
911 // create the inititalizer | 898 // create the inititalizer |
912 LLConstant* tiInit = llvm::ConstantStruct::get(sinits); | 899 LLConstant* tiInit = llvm::ConstantStruct::get(sinits); |
913 | 900 |
914 // refine global type | 901 // refine global type |
934 const LLStructType* stype = isaStruct(base->type->ir.type->get()); | 921 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
935 | 922 |
936 // initializer vector | 923 // initializer vector |
937 std::vector<LLConstant*> sinits; | 924 std::vector<LLConstant*> sinits; |
938 // first is always the vtable | 925 // first is always the vtable |
939 sinits.push_back(base->ir.irStruct->vtbl); | 926 sinits.push_back(base->ir.irStruct->getVtblSymbol()); |
940 | 927 |
941 // monitor | 928 // monitor |
942 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); | 929 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
943 | 930 |
944 // create elements array | 931 // create elements array |