本文整理汇总了C++中Dsymbol::apply方法的典型用法代码示例。如果您正苦于以下问题:C++ Dsymbol::apply方法的具体用法?C++ Dsymbol::apply怎么用?C++ Dsymbol::apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dsymbol
的用法示例。
在下文中一共展示了Dsymbol::apply方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: size
unsigned AggregateDeclaration::size(Loc loc)
{
//printf("AggregateDeclaration::size() %s, scope = %p\n", toChars(), scope);
if (loc.linnum == 0)
loc = this->loc;
if (sizeok != SIZEOKdone && scope)
semantic(NULL);
StructDeclaration *sd = isStructDeclaration();
if (sizeok != SIZEOKdone && sd && sd->members)
{
/* See if enough is done to determine the size,
* meaning all the fields are done.
*/
struct SV
{
/* Returns:
* 0 this member doesn't need further processing to determine struct size
* 1 this member does
*/
static int func(Dsymbol *s, void *param)
{
VarDeclaration *v = s->isVarDeclaration();
if (v)
{
if (v->scope)
v->semantic(NULL);
if (v->storage_class & (STCstatic | STCextern | STCtls | STCgshared | STCmanifest | STCctfe | STCtemplateparameter))
return 0;
if (v->isField() && v->sem >= SemanticDone)
return 0;
return 1;
}
return 0;
}
};
SV sv;
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
if (s->apply(&SV::func, &sv))
goto L1;
}
sd->finalizeSize(NULL);
L1: ;
}
if (!members)
{
error(loc, "unknown size");
}
else if (sizeok != SIZEOKdone)
{
error(loc, "no size yet for forward reference");
//*(char*)0=0;
}
return structsize;
}
示例2: apply
int Nspace::apply(Dsymbol_apply_ft_t fp, void *param)
{
if (members)
{
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
if (s)
{
if (s->apply(fp, param))
return 1;
}
}
}
return 0;
}
示例3: apply
int AttribDeclaration::apply(Dsymbol_apply_ft_t fp, void *param)
{
Dsymbols *d = include(scope, NULL);
if (d)
{
for (size_t i = 0; i < d->dim; i++)
{ Dsymbol *s = (*d)[i];
if (s)
{
if (s->apply(fp, param))
return 1;
}
}
}
return 0;
}
示例4: toDebug
//.........这里部分代码省略.........
TOWORD(d->data + 2,0); // count: number of fields is 0
TOWORD(d->data + 4,0); // field list is 0
TOWORD(d->data + 6,property);
}
return /*typidx*/;
}
// Compute the number of fields (nfields), and the length of the fieldlist record (fnamelen)
CvMemberCount mc;
mc.nfields = 0;
mc.fnamelen = 2;
/* Adding in the base classes causes VS 2010 debugger to refuse to display any
* of the fields. I have not been able to determine why.
* (Could it be because the base class is "forward referenced"?)
* It does work with VS 2012.
*/
bool addInBaseClasses = true;
if (addInBaseClasses)
{
// Add in base classes
for (size_t i = 0; i < baseclasses->dim; i++)
{ BaseClass *bc = (*baseclasses)[i];
mc.nfields++;
unsigned elementlen = 4 + cgcv.sz_idx + cv4_numericbytes(bc->offset);
elementlen = cv_align(NULL, elementlen);
mc.fnamelen += elementlen;
}
}
for (size_t i = 0; i < members->dim; i++)
{ Dsymbol *s = (*members)[i];
s->apply(&cv_mem_count, &mc);
}
unsigned nfields = mc.nfields;
unsigned fnamelen = mc.fnamelen;
int count = nfields;
TOWORD(d->data + 2,count);
// Generate fieldlist type record
debtyp_t *dt = debtyp_alloc(fnamelen);
unsigned char *p = dt->data;
// And fill it in
TOWORD(p,config.fulltypes == CV8 ? LF_FIELDLIST_V2 : LF_FIELDLIST);
p += 2;
if (addInBaseClasses)
{
// Add in base classes
for (size_t i = 0; i < baseclasses->dim; i++)
{ BaseClass *bc = (*baseclasses)[i];
idx_t typidx = cv4_typidx(bc->base->type->toCtype()->Tnext);
unsigned attribute = PROTtoATTR(bc->protection);
unsigned elementlen;
switch (config.fulltypes)
{
case CV8:
TOWORD(p, LF_BCLASS_V2);
TOWORD(p + 2,attribute);
TOLONG(p + 4,typidx);
elementlen = 8;
示例5: toDebug
//.........这里部分代码省略.........
TOWORD(d->data + 10,cv_debtyp(vshape)); // vshape
}
}
else
TOWORD(d->data + 10,0); // vshape is 0 (no virtual functions)
TOWORD(d->data,leaf);
// Assign a number to prevent infinite recursion if a struct member
// references the same struct.
d->length = 0; // so cv_debtyp() will allocate new
typidx = cv_debtyp(d);
d->length = len; // restore length
if (!members) // if reference only
{
TOWORD(d->data + 2,0); // count: number of fields is 0
TOWORD(d->data + 4,0); // field list is 0
TOWORD(d->data + 6,property);
return /*typidx*/;
}
// Compute the number of fields (nfields), and the length of the fieldlist record (fnamelen)
CvMemberCount mc;
mc.nfields = 0;
mc.fnamelen = 2;
// Add in base classes
for (size_t i = 0; i < baseclasses->dim; i++)
{ BaseClass *bc = (*baseclasses)[i];
mc.nfields++;
mc.fnamelen += 6 + cv4_numericbytes(bc->offset);
}
for (size_t i = 0; i < members->dim; i++)
{ Dsymbol *s = (*members)[i];
s->apply(&cv_mem_count, &mc);
}
nfields = mc.nfields;
fnamelen = mc.fnamelen;
count = nfields;
TOWORD(d->data + 2,count);
TOWORD(d->data + 6,property);
// Generate fieldlist type record
dt = debtyp_alloc(fnamelen);
p = dt->data;
// And fill it in
TOWORD(p,LF_FIELDLIST);
p += 2;
// Add in base classes
for (size_t i = 0; i < baseclasses->dim; i++)
{ BaseClass *bc = (*baseclasses)[i];
idx_t typidx;
unsigned attribute;
typidx = cv4_typidx(bc->base->type->toCtype()->Tnext);
attribute = PROTtoATTR(bc->protection);
TOWORD(p,LF_BCLASS);
TOWORD(p + 2,typidx);
TOWORD(p + 4,attribute);
p += 6;
cv4_storenumeric(p, bc->offset);
p += cv4_numericbytes(bc->offset);
}
for (size_t i = 0; i < members->dim; i++)
{ Dsymbol *s = (*members)[i];
s->apply(&cv_mem_p, &p);
}
//dbg_printf("fnamelen = %d, p-dt->data = %d\n",fnamelen,p-dt->data);
assert(p - dt->data == fnamelen);
TOWORD(d->data + 4,cv_debtyp(dt));
// cv4_outsym(s);
unsigned char *debsym;
unsigned length;
len = strlen(id);
debsym = (unsigned char *) alloca(39 + IDOHD + len);
// Output a 'user-defined type' for the tag name
TOWORD(debsym + 2,S_UDT);
TOIDX(debsym + 4,typidx);
length = 2 + 2 + cgcv.sz_idx;
length += cv_namestring(debsym + length,id);
TOWORD(debsym,length - 2);
assert(length <= 40 + len);
obj_write_bytes(SegData[DEBSYM],length,debsym);
// return typidx;
}
示例6: finalizeSize
void StructDeclaration::finalizeSize(Scope *sc)
{
//printf("StructDeclaration::finalizeSize() %s\n", toChars());
if (sizeok != SIZEOKnone)
return;
// Set the offsets of the fields and determine the size of the struct
unsigned offset = 0;
bool isunion = isUnionDeclaration() != NULL;
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->setFieldOffset(this, &offset, isunion);
}
if (sizeok == SIZEOKfwd)
return;
// 0 sized struct's are set to 1 byte
if (structsize == 0)
{
structsize = 1;
alignsize = 1;
}
// Round struct size up to next alignsize boundary.
// This will ensure that arrays of structs will get their internals
// aligned properly.
if (alignment == STRUCTALIGN_DEFAULT)
structsize = (structsize + alignsize - 1) & ~(alignsize - 1);
else
structsize = (structsize + alignment - 1) & ~(alignment - 1);
sizeok = SIZEOKdone;
// Calculate fields[i]->overlapped
fill(loc, NULL, true);
// Determine if struct is all zeros or not
zeroInit = 1;
for (size_t i = 0; i < fields.dim; i++)
{
VarDeclaration *vd = fields[i];
if (!vd->isDataseg())
{
if (vd->init)
{
// Should examine init to see if it is really all 0's
zeroInit = 0;
break;
}
else
{
if (!vd->type->isZeroInit(loc))
{
zeroInit = 0;
break;
}
}
}
}
// Look for the constructor, for the struct literal/constructor call expression
ctor = searchCtor();
if (ctor)
{
// Finish all constructors semantics to determine this->noDefaultCtor.
struct SearchCtor
{
static int fp(Dsymbol *s, void *ctxt)
{
CtorDeclaration *f = s->isCtorDeclaration();
if (f && f->semanticRun == PASSinit)
f->semantic(NULL);
return 0;
}
};
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->apply(&SearchCtor::fp, NULL);
}
}
}
示例7: size
unsigned AggregateDeclaration::size(Loc loc)
{
//printf("AggregateDeclaration::size() %s, scope = %p\n", toChars(), scope);
if (loc.linnum == 0)
loc = this->loc;
if (sizeok != SIZEOKdone && scope)
{
semantic(NULL);
// Determine the instance size of base class first.
if (ClassDeclaration *cd = isClassDeclaration())
cd->baseClass->size(loc);
}
if (sizeok != SIZEOKdone && members)
{
/* See if enough is done to determine the size,
* meaning all the fields are done.
*/
struct SV
{
/* Returns:
* 0 this member doesn't need further processing to determine struct size
* 1 this member does
*/
static int func(Dsymbol *s, void *param)
{
VarDeclaration *v = s->isVarDeclaration();
if (v)
{
/* Bugzilla 12799: enum a = ...; is a VarDeclaration and
* STCmanifest is already set in parssing stage. So we can
* check this before the semantic() call.
*/
if (v->storage_class & STCmanifest)
return 0;
if (v->scope)
v->semantic(NULL);
if (v->storage_class & (STCstatic | STCextern | STCtls | STCgshared | STCmanifest | STCctfe | STCtemplateparameter))
return 0;
if (v->isField() && v->sem >= SemanticDone)
return 0;
return 1;
}
return 0;
}
};
SV sv;
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
if (s->apply(&SV::func, &sv))
goto L1;
}
finalizeSize(NULL);
L1: ;
}
if (!members)
{
error(loc, "unknown size");
}
else if (sizeok != SIZEOKdone)
{
error(loc, "no size yet for forward reference");
//*(char*)0=0;
}
return structsize;
}