Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Changeset 816:7d16ce7ad19d

Show
Ignore:
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
  • dmd/attrib.c

    r797 r816  
    3333 
    3434#include "../gen/enums.h" 
    35 #include "../gen/logger.h" 
    3635 
    3736extern void obj_includelib(const char *name); 
  • dmd2/attrib.c

    r797 r816  
    3333 
    3434#include "../gen/enums.h" 
    35 #include "../gen/logger.h" 
    3635 
    3736extern void obj_includelib(const char *name); 
  • gen/classes.cpp

    r812 r816  
    5252    else 
    5353        irstruct->interfaceMap.insert(std::make_pair(b->base, iri)); 
     54 
    5455    // add to ordered list 
    5556    irstruct->interfaceVec.push_back(iri); 
     57 
     58    // add to classinfo interfaces 
     59    if (newinstance) 
     60        irstruct->classInfoInterfaces.push_back(iri); 
    5661 
    5762    // assign this iri to all base interfaces of this one 
     
    149154            IrInterface* iri = new IrInterface(bc); 
    150155            irstruct->interfaceVec.push_back(iri); 
     156            irstruct->classInfoInterfaces.push_back(iri); 
    151157        } 
    152158    } 
     
    379385    // interface vtables 
    380386    unsigned idx = 0; 
    381  
    382387    for (IrStruct::InterfaceVectorIter i=irstruct->interfaceVec.begin(); i!=irstruct->interfaceVec.end(); ++i) 
    383388    { 
     
    393398        iri->vtbl = new llvm::GlobalVariable(iri->vtblInitTy.get(), true, _linkage, 0, nam, gIR->module); 
    394399 
    395         // always create interfaceinfos 
     400        // always set the interface info as it's need as the first vtbl entry 
    396401        LLConstant* idxs[2] = {DtoConstUint(0), DtoConstUint(idx)}; 
    397402        iri->info = llvm::ConstantExpr::getGetElementPtr(irstruct->interfaceInfos, idxs, 2); 
     
    15071512    else { 
    15081513        const LLType* t = intersTy->getContainedType(1); // .ptr 
     1514        // cast to Interface* 
    15091515        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 
    15111523        c = DtoConstSlice(DtoConstSize_t(iisz), c); 
    15121524    } 
  • ir/irstruct.h

    r806 r816  
    143143    bool classInfoDeclared; 
    144144    bool classInfoDefined; 
     145    // vector of interfaces that should be put in ClassInfo.interfaces 
     146    InterfaceVector classInfoInterfaces; 
    145147 
    146148    // align(1) struct S { ... } 
Copyright © 2008, LDC Development Team.