Mercurial > projects > ldc
comparison ir/irtypeclass.cpp @ 1230:e67c85d6e680
Completed interface implementation. Hopefully that's it for now..
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Thu, 16 Apr 2009 13:18:56 +0200 |
parents | 79758fd2f48a |
children | 212ec2d9d176 |
comparison
equal
deleted
inserted
replaced
1229:fafe7c8d6734 | 1230:e67c85d6e680 |
---|---|
22 cd(cd), | 22 cd(cd), |
23 tc((TypeClass*)cd->type), | 23 tc((TypeClass*)cd->type), |
24 vtbl_pa(llvm::OpaqueType::get()) | 24 vtbl_pa(llvm::OpaqueType::get()) |
25 { | 25 { |
26 vtbl_size = cd->vtbl.dim; | 26 vtbl_size = cd->vtbl.dim; |
27 num_interface_vtbls = 0; | |
27 } | 28 } |
28 | 29 |
29 ////////////////////////////////////////////////////////////////////////////// | 30 ////////////////////////////////////////////////////////////////////////////// |
30 | 31 |
31 void IrTypeClass::addBaseClassData( | 32 void IrTypeClass::addBaseClassData( |
89 { | 90 { |
90 bool new_instances = (base == cd); | 91 bool new_instances = (base == cd); |
91 | 92 |
92 ArrayIter<BaseClass> it2(*base->vtblInterfaces); | 93 ArrayIter<BaseClass> it2(*base->vtblInterfaces); |
93 | 94 |
95 VarDeclarationIter interfaces_idx(ClassDeclaration::classinfo->fields, 3); | |
96 Type* first = interfaces_idx->type->next->pointerTo(); | |
97 | |
94 for (; !it2.done(); it2.next()) | 98 for (; !it2.done(); it2.next()) |
95 { | 99 { |
96 BaseClass* b = it2.get(); | 100 BaseClass* b = it2.get(); |
97 IF_LOG Logger::println("Adding interface vtbl for %s", b->base->toPrettyChars()); | 101 IF_LOG Logger::println("Adding interface vtbl for %s", b->base->toPrettyChars()); |
98 | 102 |
99 Array arr; | 103 Array arr; |
100 b->fillVtbl(cd, &arr, new_instances); | 104 b->fillVtbl(cd, &arr, new_instances); |
101 | 105 |
102 const llvm::Type* ivtbl_type = buildVtblType(Type::tvoid->pointerTo(), &arr); | 106 const llvm::Type* ivtbl_type = buildVtblType(first, &arr); |
103 defaultTypes.push_back(llvm::PointerType::get(ivtbl_type, 0)); | 107 defaultTypes.push_back(llvm::PointerType::get(ivtbl_type, 0)); |
104 | 108 |
105 offset += PTRSIZE; | 109 offset += PTRSIZE; |
106 | 110 |
107 // add to the interface map | 111 // add to the interface map |
112 // FIXME: and all it's baseinterfaces | |
108 if (interfaceMap.find(b->base) == interfaceMap.end()) | 113 if (interfaceMap.find(b->base) == interfaceMap.end()) |
109 interfaceMap.insert(std::make_pair(b->base, field_index)); | 114 interfaceMap.insert(std::make_pair(b->base, field_index)); |
110 field_index++; | 115 field_index++; |
116 | |
117 // inc count | |
118 num_interface_vtbls++; | |
111 } | 119 } |
112 } | 120 } |
113 | 121 |
114 // tail padding? | 122 // tail padding? |
115 if (offset < base->structsize) | 123 if (offset < base->structsize) |