本文整理汇总了C++中SgVariableDeclaration::get_bitfield方法的典型用法代码示例。如果您正苦于以下问题:C++ SgVariableDeclaration::get_bitfield方法的具体用法?C++ SgVariableDeclaration::get_bitfield怎么用?C++ SgVariableDeclaration::get_bitfield使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgVariableDeclaration
的用法示例。
在下文中一共展示了SgVariableDeclaration::get_bitfield方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layoutType
StructLayoutInfo NonpackedTypeLayoutGenerator::layoutType(SgType* t) const {
switch (t->variantT()) {
case V_SgClassType: { // Also covers structs and unions
SgClassDeclaration* decl = isSgClassDeclaration(isSgClassType(t)->get_declaration());
ROSE_ASSERT (decl);
decl = isSgClassDeclaration(decl->get_definingDeclaration());
ROSE_ASSERT (decl);
SgClassDefinition* def = decl->get_definition();
ROSE_ASSERT (def);
StructLayoutInfo layout;
size_t currentOffset = 0;
const SgBaseClassPtrList& bases = def->get_inheritances();
for (SgBaseClassPtrList::const_iterator i = bases.begin();
i != bases.end(); ++i) {
SgBaseClass* base = *i;
SgClassDeclaration* basecls = base->get_base_class();
layoutOneField(basecls->get_type(), base, false, currentOffset, layout);
}
const SgDeclarationStatementPtrList& body = def->get_members();
bool isUnion = (decl->get_class_type() == SgClassDeclaration::e_union);
for (SgDeclarationStatementPtrList::const_iterator i = body.begin();
i != body.end(); ++i) {
SgDeclarationStatement* mem = *i;
SgVariableDeclaration* vardecl = isSgVariableDeclaration(mem);
SgClassDeclaration* classdecl = isSgClassDeclaration(mem);
bool isUnnamedUnion = classdecl ? classdecl->get_isUnNamed() : false;
if (vardecl) {
if (!vardecl->get_declarationModifier().isDefault()) continue; // Static fields and friends
ROSE_ASSERT (!vardecl->get_bitfield());
const SgInitializedNamePtrList& vars = isSgVariableDeclaration(mem)->get_variables();
for (SgInitializedNamePtrList::const_iterator j = vars.begin();
j != vars.end(); ++j) {
SgInitializedName* var = *j;
layoutOneField(var->get_type(), var, isUnion, currentOffset, layout);
}
} else if (isUnnamedUnion) {
layoutOneField(classdecl->get_type(), classdecl, isUnion, currentOffset, layout);
} // else continue;
}
if (layout.alignment != 0 && layout.size % layout.alignment != 0) {
size_t paddingNeeded = layout.alignment - (layout.size % layout.alignment);
if (!isUnion) {
layout.fields.push_back(StructLayoutEntry(NULL, layout.size, paddingNeeded));
}
layout.size += paddingNeeded;
}
return layout;
}
case V_SgArrayType: {
StructLayoutInfo layout = this->beginning->layoutType(isSgArrayType(t)->get_base_type());
layout.fields.clear();
SgExpression* numElements = isSgArrayType(t)->get_index();
//Adjustment for UPC array like a[100*THREADS],treat it as a[100]
// Liao, 8/7/2008
if (isUpcArrayWithThreads(isSgArrayType(t)))
{
SgMultiplyOp* multiply = isSgMultiplyOp(isSgArrayType(t)->get_index());
ROSE_ASSERT(multiply);
// DQ (9/26/2011): Do constant folding if required.
// SageInterface::constantFolding(multiply);
numElements = multiply->get_lhs_operand();
}
if (!isSgValueExp(numElements)) {
cerr << "Error: trying to compute static size of an array with non-constant size" << endl;
abort();
}
layout.size *= SageInterface::getIntegerConstantValue(isSgValueExp(numElements));
return layout;
}
case V_SgTypeComplex: {
//"Each complex type has the same representation and alignment requirements as
//an array type containing exactly two elements of the corresponding real type"
StructLayoutInfo layout = this->beginning->layoutType(isSgTypeComplex(t)->get_base_type());
layout.size *= 2;
return layout;
}
case V_SgTypeImaginary: {
StructLayoutInfo layout = this->beginning->layoutType(isSgTypeImaginary(t)->get_base_type());
return layout;
}
default: return ChainableTypeLayoutGenerator::layoutType(t);
}
}