本文整理汇总了C++中LLStructType::getElementType方法的典型用法代码示例。如果您正苦于以下问题:C++ LLStructType::getElementType方法的具体用法?C++ LLStructType::getElementType怎么用?C++ LLStructType::getElementType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLStructType
的用法示例。
在下文中一共展示了LLStructType::getElementType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DtoCreateNestedContextType
static void DtoCreateNestedContextType(FuncDeclaration* fd) {
Logger::println("DtoCreateNestedContextType for %s", fd->toChars());
LOG_SCOPE
DtoDeclareFunction(fd);
if (fd->ir.irFunc->nestedContextCreated)
return;
fd->ir.irFunc->nestedContextCreated = true;
if (fd->nestedVars.empty()) {
// fill nestedVars
size_t nnest = fd->closureVars.dim;
for (size_t i = 0; i < nnest; ++i)
{
VarDeclaration* vd = static_cast<VarDeclaration*>(fd->closureVars.data[i]);
fd->nestedVars.insert(vd);
}
}
// construct nested variables array
if (!fd->nestedVars.empty())
{
Logger::println("has nested frame");
// start with adding all enclosing parent frames until a static parent is reached
LLStructType* innerFrameType = NULL;
unsigned depth = -1;
if (!fd->isStatic()) {
if (FuncDeclaration* parfd = getParentFunc(fd, true)) {
// Make sure the parent has already been analyzed.
DtoCreateNestedContextType(parfd);
innerFrameType = parfd->ir.irFunc->frameType;
if (innerFrameType)
depth = parfd->ir.irFunc->depth;
}
}
fd->ir.irFunc->depth = ++depth;
Logger::cout() << "Function " << fd->toChars() << " has depth " << depth << '\n';
typedef std::vector<LLType*> TypeVec;
TypeVec types;
if (depth != 0) {
assert(innerFrameType);
// Add frame pointer types for all but last frame
if (depth > 1) {
for (unsigned i = 0; i < (depth - 1); ++i) {
types.push_back(innerFrameType->getElementType(i));
}
}
// Add frame pointer type for last frame
types.push_back(LLPointerType::getUnqual(innerFrameType));
}
if (Logger::enabled() && depth != 0) {
Logger::println("Frame types: ");
LOG_SCOPE;
for (TypeVec::iterator i = types.begin(); i != types.end(); ++i)
Logger::cout() << **i << '\n';
}
// Add the direct nested variables of this function, and update their indices to match.
// TODO: optimize ordering for minimal space usage?
for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i)
{
VarDeclaration* vd = *i;
if (!vd->ir.irLocal)
vd->ir.irLocal = new IrLocal(vd);
vd->ir.irLocal->nestedIndex = types.size();
vd->ir.irLocal->nestedDepth = depth;
if (vd->isParameter()) {
// Parameters will have storage associated with them (to handle byref etc.),
// so handle those cases specially by storing a pointer instead of a value.
const IrParameter* irparam = vd->ir.irParam;
const bool refout = vd->storage_class & (STCref | STCout);
const bool lazy = vd->storage_class & STClazy;
const bool byref = irparam->arg->byref;
const bool isVthisPtr = irparam->isVthis && !byref;
if (!(refout || (byref && !lazy)) || isVthisPtr) {
// This will be copied to the nesting frame.
if (lazy)
types.push_back(irparam->value->getType()->getContainedType(0));
else
types.push_back(DtoType(vd->type));
} else {
types.push_back(irparam->value->getType());
}
} else if (isSpecialRefVar(vd)) {
types.push_back(DtoType(vd->type->pointerTo()));
} else {
types.push_back(DtoType(vd->type));
}
if (Logger::enabled()) {
Logger::cout() << "Nested var '" << vd->toChars() <<
"' of type " << *types.back() << "\n";
}
}
//.........这里部分代码省略.........