本文整理汇总了C++中Dsymbol::isStructDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C++ Dsymbol::isStructDeclaration方法的具体用法?C++ Dsymbol::isStructDeclaration怎么用?C++ Dsymbol::isStructDeclaration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dsymbol
的用法示例。
在下文中一共展示了Dsymbol::isStructDeclaration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
Symbol *FuncDeclaration::toSymbol()
{
if (!csym)
{ Symbol *s;
TYPE *t;
const char *id;
#if 0
id = ident->toChars();
#else
id = mangle();
#endif
//printf("FuncDeclaration::toSymbol(%s %s)\n", kind(), toChars());
//printf("\tid = '%s'\n", id);
//printf("\ttype = %s\n", type->toChars());
s = symbol_calloc(id);
slist_add(s);
{
s->prettyIdent = toPrettyChars();
s->Sclass = SCglobal;
symbol_func(s);
func_t *f = s->Sfunc;
if (isVirtual() && vtblIndex != -1)
f->Fflags |= Fvirtual;
else if (isMember2() && isStatic())
f->Fflags |= Fstatic;
f->Fstartline.Slinnum = loc.linnum;
f->Fstartline.Sfilename = (char *)loc.filename;
if (endloc.linnum)
{ f->Fendline.Slinnum = endloc.linnum;
f->Fendline.Sfilename = (char *)endloc.filename;
}
else
{ f->Fendline.Slinnum = loc.linnum;
f->Fendline.Sfilename = (char *)loc.filename;
}
t = type->toCtype();
}
mangle_t msave = t->Tmangle;
if (isMain())
{
t->Tty = TYnfunc;
t->Tmangle = mTYman_c;
}
else
{
switch (linkage)
{
case LINKwindows:
t->Tmangle = mTYman_std;
break;
case LINKpascal:
t->Tty = TYnpfunc;
t->Tmangle = mTYman_pas;
break;
case LINKc:
t->Tmangle = mTYman_c;
break;
case LINKd:
t->Tmangle = mTYman_d;
break;
case LINKcpp:
{ t->Tmangle = mTYman_cpp;
if (isThis() && !global.params.is64bit && global.params.isWindows)
t->Tty = TYmfunc;
s->Sflags |= SFLpublic;
Dsymbol *parent = toParent();
ClassDeclaration *cd = parent->isClassDeclaration();
if (cd)
{
::type *tc = cd->type->toCtype();
s->Sscope = tc->Tnext->Ttag;
}
StructDeclaration *sd = parent->isStructDeclaration();
if (sd)
{
::type *ts = sd->type->toCtype();
s->Sscope = ts->Ttag;
}
break;
}
default:
printf("linkage = %d\n", linkage);
assert(0);
}
}
if (msave)
assert(msave == t->Tmangle);
//printf("Tty = %x, mangle = x%x\n", t->Tty, t->Tmangle);
t->Tcount++;
s->Stype = t;
//s->Sfielddef = this;
csym = s;
//.........这里部分代码省略.........
示例2: if
//.........这里部分代码省略.........
}
}
//if (fdparent != thisfd) ethis = el_bin(OPadd, TYnptr, ethis, el_long(TYint, 0x18));
}
else
{
if (!irs->sthis) // if no frame pointer for this function
{
fd->error(loc, "is a nested function and cannot be accessed from %s", irs->getFunc()->toPrettyChars());
ethis = el_long(TYnptr, 0); // error recovery
}
else
{
ethis = el_var(irs->sthis);
Dsymbol *s = thisfd;
while (fd != s)
{ /* Go up a nesting level, i.e. we need to find the 'this'
* of an enclosing function.
* Our 'enclosing function' may also be an inner class.
*/
//printf("\ts = '%s'\n", s->toChars());
thisfd = s->isFuncDeclaration();
if (thisfd)
{ /* Enclosing function is a function.
*/
if (fdparent == s->toParent2())
break;
if (thisfd->isNested())
{
FuncDeclaration *p = s->toParent2()->isFuncDeclaration();
if (!p || p->hasNestedFrameRefs())
ethis = el_una(OPind, TYnptr, ethis);
}
else if (thisfd->vthis)
{
}
else
{ // Error should have been caught by front end
assert(0);
}
}
else
{ /* Enclosed by an aggregate. That means the current
* function must be a member function of that aggregate.
*/
ClassDeclaration *cd;
StructDeclaration *sd;
AggregateDeclaration *ad = s->isAggregateDeclaration();
if (!ad)
goto Lnoframe;
cd = s->isClassDeclaration();
if (cd && fd->isClassDeclaration() &&
fd->isClassDeclaration()->isBaseOf(cd, NULL))
break;
sd = s->isStructDeclaration();
if (fd == sd)
break;
if (!ad->isNested() || !ad->vthis)
{
Lnoframe:
irs->getFunc()->error(loc, "cannot get frame pointer to %s", fd->toChars());
return el_long(TYnptr, 0); // error recovery
}
ethis = el_bin(OPadd, TYnptr, ethis, el_long(TYsize_t, ad->vthis->offset));
ethis = el_una(OPind, TYnptr, ethis);
if (fdparent == s->toParent2())
break;
if (fd == s->toParent2())
{
/* Remember that frames for functions that have no
* nested references are skipped in the linked list
* of frames.
*/
if (s->toParent2()->isFuncDeclaration()->hasNestedFrameRefs())
ethis = el_una(OPind, TYnptr, ethis);
break;
}
if (s->toParent2()->isFuncDeclaration())
{
/* Remember that frames for functions that have no
* nested references are skipped in the linked list
* of frames.
*/
if (s->toParent2()->isFuncDeclaration()->hasNestedFrameRefs())
ethis = el_una(OPind, TYnptr, ethis);
}
}
s = s->toParent2();
assert(s);
}
}
}
#if 0
printf("ethis:\n");
elem_print(ethis);
printf("\n");
#endif
return ethis;
}
示例3: fill
/***************************************
* Fill out remainder of elements[] with default initializers for fields[].
* Input:
* loc
* elements explicit arguments which given to construct object.
* ctorinit true if the elements will be used for default initialization.
* Returns false if any errors occur.
* Otherwise, returns true and the missing arguments will be pushed in elements[].
*/
bool StructDeclaration::fill(Loc loc, Expressions *elements, bool ctorinit)
{
//printf("StructDeclaration::fill() %s\n", toChars());
assert(sizeok == SIZEOKdone);
size_t nfields = fields.dim - isNested();
bool errors = false;
if (elements)
{
size_t dim = elements->dim;
elements->setDim(nfields);
for (size_t i = dim; i < nfields; i++)
(*elements)[i] = NULL;
}
// Fill in missing any elements with default initializers
for (size_t i = 0; i < nfields; i++)
{
if (elements && (*elements)[i])
continue;
VarDeclaration *vd = fields[i];
VarDeclaration *vx = vd;
if (vd->init && vd->init->isVoidInitializer())
vx = NULL;
// Find overlapped fields with the hole [vd->offset .. vd->offset->size()].
size_t fieldi = i;
for (size_t j = 0; j < nfields; j++)
{
if (i == j)
continue;
VarDeclaration *v2 = fields[j];
bool overlap = (vd->offset < v2->offset + v2->type->size() &&
v2->offset < vd->offset + vd->type->size());
if (!overlap)
continue;
// vd and v2 are overlapping. If either has destructors, postblits, etc., then error
//printf("overlapping fields %s and %s\n", vd->toChars(), v2->toChars());
VarDeclaration *v = vd;
for (int k = 0; k < 2; ++k, v = v2)
{
Type *tv = v->type->baseElemOf();
Dsymbol *sv = tv->toDsymbol(NULL);
if (sv && !errors)
{
StructDeclaration *sd = sv->isStructDeclaration();
if (sd && (sd->dtor || sd->inv || sd->postblit))
{
error("destructors, postblits and invariants are not allowed in overlapping fields %s and %s", vd->toChars(), v2->toChars());
errors = true;
break;
}
}
}
if (elements)
{
if ((*elements)[j])
{
vx = NULL;
break;
}
}
else
{
vd->overlapped = true;
}
if (v2->init && v2->init->isVoidInitializer())
continue;
if (elements)
{
/* Prefer first found non-void-initialized field
* union U { int a; int b = 2; }
* U u; // Error: overlapping initialization for field a and b
*/
if (!vx)
vx = v2, fieldi = j;
else if (v2->init)
{
::error(loc, "overlapping initialization for field %s and %s",
v2->toChars(), vd->toChars());
}
}
else
{
// Will fix Bugzilla 1432 by enabling this path always
/* Prefer explicitly initialized field
* union U { int a; int b = 2; }
//.........这里部分代码省略.........