comparison gen/typinf.cpp @ 1245:465a77c904d4

Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Fri, 17 Apr 2009 14:38:29 +0200
parents 79758fd2f48a
children 450897f5aae9
comparison
equal deleted inserted replaced
1244:e1b0c5c74c58 1245:465a77c904d4
636 void TypeInfoStructDeclaration::llvmDefine() 636 void TypeInfoStructDeclaration::llvmDefine()
637 { 637 {
638 Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", toChars()); 638 Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", toChars());
639 LOG_SCOPE; 639 LOG_SCOPE;
640 640
641 // make sure struct is resolved
641 assert(tinfo->ty == Tstruct); 642 assert(tinfo->ty == Tstruct);
642 TypeStruct *tc = (TypeStruct *)tinfo; 643 TypeStruct *tc = (TypeStruct *)tinfo;
643 StructDeclaration *sd = tc->sym; 644 StructDeclaration *sd = tc->sym;
644 sd->codegen(Type::sir); 645 sd->codegen(Type::sir);
645 646
833 void TypeInfoClassDeclaration::llvmDefine() 834 void TypeInfoClassDeclaration::llvmDefine()
834 { 835 {
835 Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars()); 836 Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars());
836 LOG_SCOPE; 837 LOG_SCOPE;
837 838
839 // make sure class is resolved
840 assert(tinfo->ty == Tclass);
841 TypeClass *tc = (TypeClass *)tinfo;
842 tc->sym->codegen(Type::sir);
843
838 // init typeinfo class 844 // init typeinfo class
839 ClassDeclaration* base = Type::typeinfoclass; 845 ClassDeclaration* base = Type::typeinfoclass;
840 assert(base); 846 assert(base);
841 base->codegen(Type::sir); 847 base->codegen(Type::sir);
842 848
847 853
848 // monitor 854 // monitor
849 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); 855 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
850 856
851 // get classinfo 857 // get classinfo
858 sinits.push_back(tc->sym->ir.irStruct->getClassInfoSymbol());
859
860 // create the inititalizer
861 LLConstant* tiInit = llvm::ConstantStruct::get(sinits);
862
863 // refine global type
864 llvm::cast<llvm::OpaqueType>(ir.irGlobal->type.get())->refineAbstractTypeTo(tiInit->getType());
865
866 // set the initializer
867 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
868 }
869
870 /* ========================================================================= */
871
872 void TypeInfoInterfaceDeclaration::llvmDefine()
873 {
874 Logger::println("TypeInfoInterfaceDeclaration::llvmDefine() %s", toChars());
875 LOG_SCOPE;
876
877 // make sure interface is resolved
852 assert(tinfo->ty == Tclass); 878 assert(tinfo->ty == Tclass);
853 TypeClass *tc = (TypeClass *)tinfo; 879 TypeClass *tc = (TypeClass *)tinfo;
854
855 tc->sym->codegen(Type::sir); 880 tc->sym->codegen(Type::sir);
856
857 sinits.push_back(tc->sym->ir.irStruct->getClassInfoSymbol());
858
859 // create the inititalizer
860 LLConstant* tiInit = llvm::ConstantStruct::get(sinits);
861
862 // refine global type
863 llvm::cast<llvm::OpaqueType>(ir.irGlobal->type.get())->refineAbstractTypeTo(tiInit->getType());
864
865 // set the initializer
866 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
867 }
868
869 /* ========================================================================= */
870
871 void TypeInfoInterfaceDeclaration::llvmDefine()
872 {
873 Logger::println("TypeInfoInterfaceDeclaration::llvmDefine() %s", toChars());
874 LOG_SCOPE;
875 881
876 // init typeinfo class 882 // init typeinfo class
877 ClassDeclaration* base = Type::typeinfointerface; 883 ClassDeclaration* base = Type::typeinfointerface;
878 assert(base); 884 assert(base);
879 base->codegen(Type::sir); 885 base->codegen(Type::sir);
888 894
889 // monitor 895 // monitor
890 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); 896 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
891 897
892 // get classinfo 898 // get classinfo
893 assert(tinfo->ty == Tclass);
894 TypeClass *tc = (TypeClass *)tinfo;
895
896 sinits.push_back(tc->sym->ir.irStruct->getClassInfoSymbol()); 899 sinits.push_back(tc->sym->ir.irStruct->getClassInfoSymbol());
897 900
898 // create the inititalizer 901 // create the inititalizer
899 LLConstant* tiInit = llvm::ConstantStruct::get(sinits); 902 LLConstant* tiInit = llvm::ConstantStruct::get(sinits);
900 903