Changeset 816:7d16ce7ad19d
- Timestamp:
- 12/01/08 12:34:02
(1 month ago)
- Author:
- Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
- branch:
- default
- Message:
Made ClassInfo?.interfaces generation consistent with DMD, fixes #134
Removed unneeded includes from dmd/attrib.c
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r797 |
r816 |
|
| 33 | 33 | |
|---|
| 34 | 34 | #include "../gen/enums.h" |
|---|
| 35 | | #include "../gen/logger.h" |
|---|
| 36 | 35 | |
|---|
| 37 | 36 | extern void obj_includelib(const char *name); |
|---|
| r797 |
r816 |
|
| 33 | 33 | |
|---|
| 34 | 34 | #include "../gen/enums.h" |
|---|
| 35 | | #include "../gen/logger.h" |
|---|
| 36 | 35 | |
|---|
| 37 | 36 | extern void obj_includelib(const char *name); |
|---|
| r812 |
r816 |
|
| 52 | 52 | else |
|---|
| 53 | 53 | irstruct->interfaceMap.insert(std::make_pair(b->base, iri)); |
|---|
| | 54 | |
|---|
| 54 | 55 | // add to ordered list |
|---|
| 55 | 56 | irstruct->interfaceVec.push_back(iri); |
|---|
| | 57 | |
|---|
| | 58 | // add to classinfo interfaces |
|---|
| | 59 | if (newinstance) |
|---|
| | 60 | irstruct->classInfoInterfaces.push_back(iri); |
|---|
| 56 | 61 | |
|---|
| 57 | 62 | // assign this iri to all base interfaces of this one |
|---|
| … | … | |
| 149 | 154 | IrInterface* iri = new IrInterface(bc); |
|---|
| 150 | 155 | irstruct->interfaceVec.push_back(iri); |
|---|
| | 156 | irstruct->classInfoInterfaces.push_back(iri); |
|---|
| 151 | 157 | } |
|---|
| 152 | 158 | } |
|---|
| … | … | |
| 379 | 385 | // interface vtables |
|---|
| 380 | 386 | unsigned idx = 0; |
|---|
| 381 | | |
|---|
| 382 | 387 | for (IrStruct::InterfaceVectorIter i=irstruct->interfaceVec.begin(); i!=irstruct->interfaceVec.end(); ++i) |
|---|
| 383 | 388 | { |
|---|
| … | … | |
| 393 | 398 | iri->vtbl = new llvm::GlobalVariable(iri->vtblInitTy.get(), true, _linkage, 0, nam, gIR->module); |
|---|
| 394 | 399 | |
|---|
| 395 | | // always create interfaceinfos |
|---|
| | 400 | // always set the interface info as it's need as the first vtbl entry |
|---|
| 396 | 401 | LLConstant* idxs[2] = {DtoConstUint(0), DtoConstUint(idx)}; |
|---|
| 397 | 402 | iri->info = llvm::ConstantExpr::getGetElementPtr(irstruct->interfaceInfos, idxs, 2); |
|---|
| … | … | |
| 1507 | 1512 | else { |
|---|
| 1508 | 1513 | const LLType* t = intersTy->getContainedType(1); // .ptr |
|---|
| | 1514 | // cast to Interface* |
|---|
| 1509 | 1515 | c = DtoBitCast(ir->interfaceInfos, t); |
|---|
| 1510 | | size_t iisz = ir->interfaceVec.size(); |
|---|
| | 1516 | size_t isz = ir->interfaceVec.size(); |
|---|
| | 1517 | size_t iisz = ir->classInfoInterfaces.size(); |
|---|
| | 1518 | assert(iisz <= isz); |
|---|
| | 1519 | // offset - we only want the 'iisz' last ones |
|---|
| | 1520 | LLConstant* idx = DtoConstUint(isz - iisz); |
|---|
| | 1521 | c = llvm::ConstantExpr::getGetElementPtr(c, &idx, 1); |
|---|
| | 1522 | // make array |
|---|
| 1511 | 1523 | c = DtoConstSlice(DtoConstSize_t(iisz), c); |
|---|
| 1512 | 1524 | } |
|---|
| r806 |
r816 |
|
| 143 | 143 | bool classInfoDeclared; |
|---|
| 144 | 144 | bool classInfoDefined; |
|---|
| | 145 | // vector of interfaces that should be put in ClassInfo.interfaces |
|---|
| | 146 | InterfaceVector classInfoInterfaces; |
|---|
| 145 | 147 | |
|---|
| 146 | 148 | // align(1) struct S { ... } |
|---|