本文整理汇总了C++中TypeStruct::isZeroInit方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeStruct::isZeroInit方法的具体用法?C++ TypeStruct::isZeroInit怎么用?C++ TypeStruct::isZeroInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeStruct
的用法示例。
在下文中一共展示了TypeStruct::isZeroInit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
//.........这里部分代码省略.........
}
if (sd->xcmp && sd->xcmp != StructDeclaration::xerrcmp &&
sd->xcmp->semanticRun >= PASSsemantic3) {
Declaration_codegen(sd->xcmp);
}
if (FuncDeclaration *ftostr = search_toString(sd)) {
if (ftostr->semanticRun >= PASSsemantic3)
Declaration_codegen(ftostr);
}
if (sd->xhash && sd->xhash->semanticRun >= PASSsemantic3) {
Declaration_codegen(sd->xhash);
}
if (sd->postblit && sd->postblit->semanticRun >= PASSsemantic3) {
Declaration_codegen(sd->postblit);
}
if (sd->dtor && sd->dtor->semanticRun >= PASSsemantic3) {
Declaration_codegen(sd->dtor);
}
if (sd->tidtor && sd->tidtor->semanticRun >= PASSsemantic3) {
Declaration_codegen(sd->tidtor);
}
}
}
IrAggr *iraggr = getIrAggr(sd);
// string name
b.push_string(sd->toPrettyChars());
// void[] m_init
// The protocol is to write a null pointer for zero-initialized arrays. The
// length field is always needed for tsize().
llvm::Constant *initPtr;
if (tc->isZeroInit(Loc())) {
initPtr = getNullValue(getVoidPtrType());
} else {
initPtr = iraggr->getInitSymbol();
}
b.push_void_array(getTypeStoreSize(DtoType(tc)), initPtr);
// function xtoHash
FuncDeclaration *fd = sd->xhash;
b.push_funcptr(fd);
// function xopEquals
fd = sd->xeq;
b.push_funcptr(fd);
// function xopCmp
fd = sd->xcmp;
b.push_funcptr(fd);
// function xtoString
fd = search_toString(sd);
b.push_funcptr(fd);
// uint m_flags
unsigned hasptrs = tc->hasPointers() ? 1 : 0;
b.push_uint(hasptrs);
// function xdtor/xdtorti
b.push_funcptr(sd->tidtor);
// function xpostblit
FuncDeclaration *xpostblit = sd->postblit;
if (xpostblit && sd->postblit->storage_class & STCdisable) {
示例2: visit
void visit(TypeInfoStructDeclaration *decl)
{
IF_LOG Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", decl->toChars());
LOG_SCOPE;
// make sure struct is resolved
assert(decl->tinfo->ty == Tstruct);
TypeStruct *tc = static_cast<TypeStruct *>(decl->tinfo);
StructDeclaration *sd = tc->sym;
// handle opaque structs
if (!sd->members) {
RTTIBuilder b(Type::typeinfostruct);
b.finalize(getIrGlobal(decl));
return;
}
// can't emit typeinfo for forward declarations
if (sd->sizeok != SIZEOKdone)
{
sd->error("cannot emit TypeInfo for forward declaration");
fatal();
}
DtoResolveStruct(sd);
IrAggr* iraggr = getIrAggr(sd);
RTTIBuilder b(Type::typeinfostruct);
// char[] name
b.push_string(sd->toPrettyChars());
// void[] init
// The protocol is to write a null pointer for zero-initialized arrays. The
// length field is always needed for tsize().
llvm::Constant *initPtr;
if (tc->isZeroInit(Loc()))
initPtr = getNullValue(getVoidPtrType());
else
initPtr = iraggr->getInitSymbol();
b.push_void_array(getTypeStoreSize(DtoType(tc)), initPtr);
// well use this module for all overload lookups
// toHash
FuncDeclaration* fd = sd->xhash;
b.push_funcptr(fd);
// opEquals
fd = sd->xeq;
b.push_funcptr(fd);
// opCmp
fd = sd->xcmp;
b.push_funcptr(fd);
// toString
fd = search_toString(sd);
b.push_funcptr(fd);
// uint m_flags;
unsigned hasptrs = tc->hasPointers() ? 1 : 0;
b.push_uint(hasptrs);
// On x86_64, class TypeInfo_Struct contains 2 additional fields
// (m_arg1/m_arg2) which are used for the X86_64 System V ABI varargs
// implementation. They are not present on any other cpu/os.
assert((global.params.targetTriple.getArch() != llvm::Triple::x86_64 && Type::typeinfostruct->fields.dim == 11) ||
(global.params.targetTriple.getArch() == llvm::Triple::x86_64 && Type::typeinfostruct->fields.dim == 13));
//void function(void*) xdtor;
b.push_funcptr(sd->dtor);
//void function(void*) xpostblit;
FuncDeclaration *xpostblit = sd->postblit;
if (xpostblit && sd->postblit->storage_class & STCdisable)
xpostblit = 0;
b.push_funcptr(xpostblit);
//uint m_align;
b.push_uint(tc->alignsize());
if (global.params.is64bit)
{
// TypeInfo m_arg1;
// TypeInfo m_arg2;
Type *t = sd->arg1type;
for (unsigned i = 0; i < 2; i++)
{
if (t)
{
t = t->merge();
b.push_typeinfo(t);
}
else
b.push_null(Type::dtypeinfo->type);
t = sd->arg2type;
}
}
//.........这里部分代码省略.........