comparison ir/irclass.cpp @ 1236:57db55766118

Fixed ClassInfo.interfaces. mini/s.d now runs again.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Thu, 16 Apr 2009 21:10:51 +0200
parents ded6a557220a
children fc579f389f9a
comparison
equal deleted inserted replaced
1235:ded6a557220a 1236:57db55766118
382 382
383 size_t n = interfacesWithVtbls.size(); 383 size_t n = interfacesWithVtbls.size();
384 assert(type->irtype->isClass()->getNumInterfaceVtbls() == n && 384 assert(type->irtype->isClass()->getNumInterfaceVtbls() == n &&
385 "inconsistent number of interface vtables in this class"); 385 "inconsistent number of interface vtables in this class");
386 386
387 VarDeclarationIter interfaces_idx(ClassDeclaration::classinfo->fields, 3);
388
387 if (n == 0) 389 if (n == 0)
388 { 390 return getNullValue(DtoType(interfaces_idx->type));
389 VarDeclarationIter idx(ClassDeclaration::classinfo->fields, 3);
390 return getNullValue(DtoType(idx->type));
391 }
392 391
393 // Build array of: 392 // Build array of:
394 // 393 //
395 // struct Interface 394 // struct Interface
396 // { 395 // {
445 n); 444 n);
446 445
447 LLConstant* arr = llvm::ConstantArray::get( 446 LLConstant* arr = llvm::ConstantArray::get(
448 array_type, 447 array_type,
449 &constants[0], 448 &constants[0],
450 constants.size()); 449 n);
451 450
452 // apply the initializer 451 // apply the initializer
453 classInterfacesArray->setInitializer(arr); 452 classInterfacesArray->setInitializer(arr);
454 453
454 // return null, only baseclass provide interfaces
455 if (cd->vtblInterfaces->dim == 0)
456 {
457 return getNullValue(DtoType(interfaces_idx->type));
458 }
459
460 // only the interface explicitly implemented by this class
461 // (not super classes) should show in ClassInfo
455 LLConstant* idxs[2] = { 462 LLConstant* idxs[2] = {
456 DtoConstSize_t(0), 463 DtoConstSize_t(0),
457 // only the interface explicitly implemented by this class
458 // (not super classes) should show in ClassInfo
459 DtoConstSize_t(n - cd->vtblInterfaces->dim) 464 DtoConstSize_t(n - cd->vtblInterfaces->dim)
460 }; 465 };
461 466
467 LLConstant* ptr = llvm::ConstantExpr::getGetElementPtr(
468 classInterfacesArray, idxs, 2);
469
462 // return as a slice 470 // return as a slice
463 return DtoConstSlice( 471 return DtoConstSlice( DtoConstSize_t(cd->vtblInterfaces->dim), ptr );
464 DtoConstSize_t(n), 472 }
465 llvm::ConstantExpr::getGetElementPtr(classInterfacesArray, idxs, 2)); 473
466 } 474 //////////////////////////////////////////////////////////////////////////////
467
468 //////////////////////////////////////////////////////////////////////////////