本文整理汇总了C++中StructDeclaration::findGetMembers方法的典型用法代码示例。如果您正苦于以下问题:C++ StructDeclaration::findGetMembers方法的具体用法?C++ StructDeclaration::findGetMembers怎么用?C++ StructDeclaration::findGetMembers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StructDeclaration
的用法示例。
在下文中一共展示了StructDeclaration::findGetMembers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toDt
void TypeInfoStructDeclaration::toDt(dt_t **pdt)
{
//printf("TypeInfoStructDeclaration::toDt() '%s'\n", toChars());
if (global.params.is64bit)
verifyStructSize(Type::typeinfostruct, 17 * Target::ptrsize);
else
verifyStructSize(Type::typeinfostruct, 15 * Target::ptrsize);
dtxoff(pdt, Type::typeinfostruct->toVtblSymbol(), 0); // vtbl for TypeInfo_Struct
dtsize_t(pdt, 0); // monitor
assert(tinfo->ty == Tstruct);
TypeStruct *tc = (TypeStruct *)tinfo;
StructDeclaration *sd = tc->sym;
if (!sd->members)
return;
/* Put out:
* char[] name;
* void[] init;
* hash_t function(in void*) xtoHash;
* bool function(in void*, in void*) xopEquals;
* int function(in void*, in void*) xopCmp;
* string function(const(void)*) xtoString;
* StructFlags m_flags;
* //xgetMembers;
* xdtor;
* xpostblit;
* uint m_align;
* version (X86_64)
* TypeInfo m_arg1;
* TypeInfo m_arg2;
* xgetRTInfo
*/
const char *name = sd->toPrettyChars();
size_t namelen = strlen(name);
dtsize_t(pdt, namelen);
dtabytes(pdt, 0, namelen + 1, name);
// void[] init;
dtsize_t(pdt, sd->structsize); // init.length
if (sd->zeroInit)
dtsize_t(pdt, 0); // NULL for 0 initialization
else
dtxoff(pdt, sd->toInitializer(), 0); // init.ptr
if (FuncDeclaration *fd = search_toHash(sd))
{
dtxoff(pdt, fd->toSymbol(), 0);
TypeFunction *tf = (TypeFunction *)fd->type;
assert(tf->ty == Tfunction);
/* I'm a little unsure this is the right way to do it. Perhaps a better
* way would to automatically add these attributes to any struct member
* function with the name "toHash".
* So I'm leaving this here as an experiment for the moment.
*/
if (!tf->isnothrow || tf->trust == TRUSTsystem /*|| tf->purity == PUREimpure*/)
warning(fd->loc, "toHash() must be declared as extern (D) size_t toHash() const nothrow @safe, not %s", tf->toChars());
}
else
dtsize_t(pdt, 0);
if (sd->xeq)
dtxoff(pdt, sd->xeq->toSymbol(), 0);
else
dtsize_t(pdt, 0);
if (sd->xcmp)
dtxoff(pdt, sd->xcmp->toSymbol(), 0);
else
dtsize_t(pdt, 0);
if (FuncDeclaration *fd = search_toString(sd))
{
dtxoff(pdt, fd->toSymbol(), 0);
}
else
dtsize_t(pdt, 0);
// StructFlags m_flags;
StructFlags::Type m_flags = 0;
if (tc->hasPointers()) m_flags |= StructFlags::hasPointers;
dtsize_t(pdt, m_flags);
#if DMDV2
#if 0
// xgetMembers
FuncDeclaration *sgetmembers = sd->findGetMembers();
if (sgetmembers)
dtxoff(pdt, sgetmembers->toSymbol(), 0);
else
dtsize_t(pdt, 0); // xgetMembers
#endif
// xdtor
FuncDeclaration *sdtor = sd->dtor;
if (sdtor)
//.........这里部分代码省略.........
示例2: toDt
//.........这里部分代码省略.........
//fdx->error("must be declared as extern (D) uint toHash()");
dtsize_t(pdt, 0);
}
}
else
dtsize_t(pdt, 0);
if (sd->xeq)
dtxoff(pdt, sd->xeq->toSymbol(), 0, TYnptr);
else
dtsize_t(pdt, 0);
s = search_function(sd, Id::cmp);
fdx = s ? s->isFuncDeclaration() : NULL;
if (fdx)
{
//printf("test1 %s, %s, %s\n", fdx->toChars(), fdx->type->toChars(), tfeqptr->toChars());
fd = fdx->overloadExactMatch(tfcmpptr);
if (fd)
{ dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
//printf("test2\n");
}
else
//fdx->error("must be declared as extern (D) int %s(%s*)", fdx->toChars(), sd->toChars());
dtsize_t(pdt, 0);
}
else
dtsize_t(pdt, 0);
s = search_function(sd, Id::tostring);
fdx = s ? s->isFuncDeclaration() : NULL;
if (fdx)
{ fd = fdx->overloadExactMatch(tftostring);
if (fd)
dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
else
//fdx->error("must be declared as extern (D) char[] toString()");
dtsize_t(pdt, 0);
}
else
dtsize_t(pdt, 0);
// uint m_flags;
size_t m_flags = tc->hasPointers();
dtsize_t(pdt, m_flags);
#if DMDV2
#if 0
// xgetMembers
FuncDeclaration *sgetmembers = sd->findGetMembers();
if (sgetmembers)
dtxoff(pdt, sgetmembers->toSymbol(), 0, TYnptr);
else
dtsize_t(pdt, 0); // xgetMembers
#endif
// xdtor
FuncDeclaration *sdtor = sd->dtor;
if (sdtor)
dtxoff(pdt, sdtor->toSymbol(), 0, TYnptr);
else
dtsize_t(pdt, 0); // xdtor
// xpostblit
FuncDeclaration *spostblit = sd->postblit;
if (spostblit && !(spostblit->storage_class & STCdisable))
dtxoff(pdt, spostblit->toSymbol(), 0, TYnptr);
else
dtsize_t(pdt, 0); // xpostblit
#endif
// uint m_align;
dtsize_t(pdt, tc->alignsize());
if (global.params.is64bit)
{
Type *t = sd->arg1type;
for (int i = 0; i < 2; i++)
{
// m_argi
if (t)
{
t->getTypeInfo(NULL);
dtxoff(pdt, t->vtinfo->toSymbol(), 0, TYnptr);
}
else
dtsize_t(pdt, 0);
t = sd->arg2type;
}
}
// xgetRTInfo
if (sd->getRTInfo)
sd->getRTInfo->toDt(pdt);
else if (m_flags)
dtsize_t(pdt, 1); // has pointers
else
dtsize_t(pdt, 0); // no pointers
}
示例3: toDt
//.........这里部分代码省略.........
}
s = search_function(sd, Id::tohash);
fdx = s ? s->isFuncDeclaration() : NULL;
if (fdx)
{ fd = fdx->overloadExactMatch(tftohash);
if (fd)
dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
else
//fdx->error("must be declared as extern (D) uint toHash()");
dtsize_t(pdt, 0);
}
else
dtsize_t(pdt, 0);
if (sd->eq)
dtxoff(pdt, sd->eq->toSymbol(), 0, TYnptr);
else
dtsize_t(pdt, 0);
s = search_function(sd, Id::cmp);
fdx = s ? s->isFuncDeclaration() : NULL;
if (fdx)
{
//printf("test1 %s, %s, %s\n", fdx->toChars(), fdx->type->toChars(), tfeqptr->toChars());
fd = fdx->overloadExactMatch(tfcmpptr);
if (fd)
{ dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
//printf("test2\n");
}
else
//fdx->error("must be declared as extern (D) int %s(%s*)", fdx->toChars(), sd->toChars());
dtsize_t(pdt, 0);
}
else
dtsize_t(pdt, 0);
s = search_function(sd, Id::tostring);
fdx = s ? s->isFuncDeclaration() : NULL;
if (fdx)
{ fd = fdx->overloadExactMatch(tftostring);
if (fd)
dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
else
//fdx->error("must be declared as extern (D) char[] toString()");
dtsize_t(pdt, 0);
}
else
dtsize_t(pdt, 0);
// uint m_flags;
dtsize_t(pdt, tc->hasPointers());
#if DMDV2
// xgetMembers
FuncDeclaration *sgetmembers = sd->findGetMembers();
if (sgetmembers)
dtxoff(pdt, sgetmembers->toSymbol(), 0, TYnptr);
else
dtsize_t(pdt, 0); // xgetMembers
// xdtor
FuncDeclaration *sdtor = sd->dtor;
if (sdtor)
dtxoff(pdt, sdtor->toSymbol(), 0, TYnptr);
else
dtsize_t(pdt, 0); // xdtor
// xpostblit
FuncDeclaration *spostblit = sd->postblit;
if (spostblit && !(spostblit->storage_class & STCdisable))
dtxoff(pdt, spostblit->toSymbol(), 0, TYnptr);
else
dtsize_t(pdt, 0); // xpostblit
#endif
// uint m_align;
dtsize_t(pdt, tc->alignsize());
if (global.params.is64bit)
{
TypeTuple *tup = tc->toArgTypes();
assert(tup->arguments->dim <= 2);
for (int i = 0; i < 2; i++)
{
if (i < tup->arguments->dim)
{
Type *targ = (tup->arguments->tdata()[i])->type;
targ = targ->merge();
targ->getTypeInfo(NULL);
dtxoff(pdt, targ->vtinfo->toSymbol(), 0, TYnptr); // m_argi
}
else
dtsize_t(pdt, 0); // m_argi
}
}
// name[]
dtnbytes(pdt, namelen + 1, name);
}
示例4: toDt
//.........这里部分代码省略.........
#if STRUCTTHISREF
// arg type is ref const T
Parameter *arg = new Parameter(STCref, tc->constOf(), NULL, NULL);
#else
// arg type is const T*
Parameter *arg = new Parameter(STCin, tc->pointerTo(), NULL, NULL);
#endif
arguments->push(arg);
tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
tfeqptr = (TypeFunction *)tfeqptr->semantic(0, &sc);
}
#if 0
TypeFunction *tfeq;
{
Scope sc;
Array *arguments = new Array;
Parameter *arg = new Parameter(In, tc, NULL, NULL);
arguments->push(arg);
tfeq = new TypeFunction(arguments, Type::tint32, 0, LINKd);
tfeq = (TypeFunction *)tfeq->semantic(0, &sc);
}
#endif
s = search_function(sd, Id::tohash);
fdx = s ? s->isFuncDeclaration() : NULL;
if (fdx)
{ fd = fdx->overloadExactMatch(tftohash);
if (fd)
dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
else
//fdx->error("must be declared as extern (D) uint toHash()");
dtdword(pdt, 0);
}
else
dtdword(pdt, 0);
s = search_function(sd, Id::eq);
fdx = s ? s->isFuncDeclaration() : NULL;
for (int i = 0; i < 2; i++)
{
if (fdx)
{ fd = fdx->overloadExactMatch(tfeqptr);
if (fd)
dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
else
//fdx->error("must be declared as extern (D) int %s(%s*)", fdx->toChars(), sd->toChars());
dtdword(pdt, 0);
}
else
//fdx->error("must be declared as extern (D) int %s(%s*)", fdx->toChars(), sd->toChars());
dtdword(pdt, 0);
s = search_function(sd, Id::cmp);
fdx = s ? s->isFuncDeclaration() : NULL;
}
s = search_function(sd, Id::tostring);
fdx = s ? s->isFuncDeclaration() : NULL;
if (fdx)
{ fd = fdx->overloadExactMatch(tftostring);
if (fd)
dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
else
//fdx->error("must be declared as extern (D) char[] toString()");
dtdword(pdt, 0);
}
else
dtdword(pdt, 0);
// uint m_flags;
dtdword(pdt, tc->hasPointers());
#if DMDV2
// xgetMembers
FuncDeclaration *sgetmembers = sd->findGetMembers();
if (sgetmembers)
dtxoff(pdt, sgetmembers->toSymbol(), 0, TYnptr);
else
dtdword(pdt, 0); // xgetMembers
// xdtor
FuncDeclaration *sdtor = sd->dtor;
if (sdtor)
dtxoff(pdt, sdtor->toSymbol(), 0, TYnptr);
else
dtdword(pdt, 0); // xdtor
// xpostblit
FuncDeclaration *spostblit = sd->postblit;
if (spostblit)
dtxoff(pdt, spostblit->toSymbol(), 0, TYnptr);
else
dtdword(pdt, 0); // xpostblit
#endif
// name[]
dtnbytes(pdt, namelen + 1, name);
}