本文整理汇总了C++中Dsymbol::isClassDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C++ Dsymbol::isClassDeclaration方法的具体用法?C++ Dsymbol::isClassDeclaration怎么用?C++ Dsymbol::isClassDeclaration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dsymbol
的用法示例。
在下文中一共展示了Dsymbol::isClassDeclaration方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
elem *setEthis(Loc loc, IRState *irs, elem *ey, AggregateDeclaration *ad)
{
elem *ethis;
FuncDeclaration *thisfd = irs->getFunc();
int offset = 0;
Dsymbol *cdp = ad->toParent2(); // class/func we're nested in
//printf("setEthis(ad = %s, cdp = %s, thisfd = %s)\n", ad->toChars(), cdp->toChars(), thisfd->toChars());
if (cdp == thisfd)
{ /* Class we're new'ing is a local class in this function:
* void thisfd() { class ad { } }
*/
if (irs->sclosure)
ethis = el_var(irs->sclosure);
else if (irs->sthis)
{
if (thisfd->hasNestedFrameRefs())
{
ethis = el_ptr(irs->sthis);
}
else
ethis = el_var(irs->sthis);
}
else
{
ethis = el_long(TYnptr, 0);
if (thisfd->hasNestedFrameRefs())
{
ethis->Eoper = OPframeptr;
}
}
}
else if (thisfd->vthis &&
(cdp == thisfd->toParent2() ||
(cdp->isClassDeclaration() &&
cdp->isClassDeclaration()->isBaseOf(thisfd->toParent2()->isClassDeclaration(), &offset)
)
)
)
{ /* Class we're new'ing is at the same level as thisfd
*/
assert(offset == 0); // BUG: should handle this case
ethis = el_var(irs->sthis);
}
else
{
ethis = getEthis(loc, irs, ad->toParent2());
ethis = el_una(OPaddr, TYnptr, ethis);
}
ey = el_bin(OPadd, TYnptr, ey, el_long(TYsize_t, ad->vthis->offset));
ey = el_una(OPind, TYnptr, ey);
ey = el_bin(OPeq, TYnptr, ey, ethis);
return ey;
}
示例2: toParent
ClassDeclaration *Dsymbol::isClassMember() // are we a member of a class?
{
Dsymbol *parent = toParent();
if (parent && parent->isClassDeclaration())
return (ClassDeclaration *)parent;
return NULL;
}
示例3: if
/*************************
* Initialize the hidden aggregate member, vthis, with
* the context pointer.
* Returns:
* *(ey + ad.vthis.offset) = this;
*/
elem *setEthis(Loc loc, IRState *irs, elem *ey, AggregateDeclaration *ad)
{
elem *ethis;
FuncDeclaration *thisfd = irs->getFunc();
int offset = 0;
Dsymbol *adp = ad->toParent2(); // class/func we're nested in
//printf("[%s] setEthis(ad = %s, adp = %s, thisfd = %s)\n", loc.toChars(), ad->toChars(), adp->toChars(), thisfd->toChars());
if (adp == thisfd)
{
ethis = getEthis(loc, irs, ad);
}
else if (thisfd->vthis &&
(adp == thisfd->toParent2() ||
(adp->isClassDeclaration() &&
adp->isClassDeclaration()->isBaseOf(thisfd->toParent2()->isClassDeclaration(), &offset)
)
)
)
{
/* Class we're new'ing is at the same level as thisfd
*/
assert(offset == 0); // BUG: should handle this case
ethis = el_var(irs->sthis);
}
else
{
ethis = getEthis(loc, irs, adp);
FuncDeclaration *fdp = adp->isFuncDeclaration();
if (fdp && fdp->hasNestedFrameRefs())
ethis = el_una(OPaddr, TYnptr, ethis);
}
ey = el_bin(OPadd, TYnptr, ey, el_long(TYsize_t, ad->vthis->offset));
ey = el_una(OPind, TYnptr, ey);
ey = el_bin(OPeq, TYnptr, ey, ethis);
return ey;
}
示例4: 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;
//.........这里部分代码省略.........
示例5: semantic
//.........这里部分代码省略.........
/* If this is a nested class, add the hidden 'this'
* member which is a pointer to the enclosing scope.
*/
if (vthis) // if inheriting from nested class
{ // Use the base class's 'this' member
isnested = true;
if (storage_class & STCstatic)
error("static class cannot inherit from nested class %s", baseClass->toChars());
if (toParent2() != baseClass->toParent2() &&
(!toParent2() ||
!baseClass->toParent2()->getType() ||
!baseClass->toParent2()->getType()->isBaseOf(toParent2()->getType(), NULL)))
{
if (toParent2())
{
error("is nested within %s, but super class %s is nested within %s",
toParent2()->toChars(),
baseClass->toChars(),
baseClass->toParent2()->toChars());
}
else
{
error("is not nested, but super class %s is nested within %s",
baseClass->toChars(),
baseClass->toParent2()->toChars());
}
isnested = false;
}
}
else if (!(storage_class & STCstatic))
{ Dsymbol *s = toParent2();
if (s)
{
AggregateDeclaration *ad = s->isClassDeclaration();
FuncDeclaration *fd = s->isFuncDeclaration();
if (ad || fd)
{ isnested = true;
Type *t;
if (ad)
t = ad->handle;
else if (fd)
{ AggregateDeclaration *ad2 = fd->isMember2();
if (ad2)
t = ad2->handle;
else
{
t = Type::tvoidptr;
}
}
else
assert(0);
if (t->ty == Tstruct) // ref to struct
t = Type::tvoidptr;
assert(!vthis);
vthis = new ThisDeclaration(loc, t);
members->push(vthis);
}
}
}
}
if (storage_class & STCauto)
error("storage class 'auto' is invalid when declaring a class, did you mean to use 'scope'?");
if (storage_class & STCscope)
示例6: ErrorExp
//.........这里部分代码省略.........
f = ve->var->isFuncDeclaration();
ex = NULL;
}
else if (ex->op == TOKdotvar)
{
DotVarExp *dve = (DotVarExp *)ex;
f = dve->var->isFuncDeclaration();
if (dve->e1->op == TOKdottype || dve->e1->op == TOKthis)
ex = NULL;
else
ex = dve->e1;
}
else
f = NULL;
Ptrait p;
p.exps = exps;
p.e1 = ex;
p.ident = e->ident;
overloadApply(f, &p, &fptraits);
TupleExp *tup = new TupleExp(e->loc, exps);
return tup->semantic(sc);
}
else
assert(0);
}
else if (e->ident == Id::classInstanceSize)
{
if (dim != 1)
goto Ldimerror;
RootObject *o = (*e->args)[0];
Dsymbol *s = getDsymbol(o);
ClassDeclaration *cd;
if (!s || (cd = s->isClassDeclaration()) == NULL)
{
e->error("first argument is not a class");
goto Lfalse;
}
if (cd->sizeok == SIZEOKnone)
{
if (cd->scope)
cd->semantic(cd->scope);
}
if (cd->sizeok != SIZEOKdone)
{
e->error("%s %s is forward referenced", cd->kind(), cd->toChars());
goto Lfalse;
}
return new IntegerExp(e->loc, cd->structsize, Type::tsize_t);
}
else if (e->ident == Id::getAliasThis)
{
if (dim != 1)
goto Ldimerror;
RootObject *o = (*e->args)[0];
Dsymbol *s = getDsymbol(o);
AggregateDeclaration *ad;
if (!s || (ad = s->isAggregateDeclaration()) == NULL)
{
e->error("argument is not an aggregate type");
goto Lfalse;
}
Expressions *exps = new Expressions();
if (ad->aliasthis)
exps->push(new StringExp(e->loc, ad->aliasthis->ident->toChars()));
示例7: if
//.........这里部分代码省略.........
/* Create tuple of virtual function overloads of e
*/
//e->dump(0);
Expressions *exps = new Expressions();
FuncDeclaration *f;
if (e->op == TOKvar)
{ VarExp *ve = (VarExp *)e;
f = ve->var->isFuncDeclaration();
}
else if (e->op == TOKdotvar)
{ DotVarExp *dve = (DotVarExp *)e;
f = dve->var->isFuncDeclaration();
}
else
f = NULL;
Pvirtuals p;
p.exps = exps;
p.e1 = e;
overloadApply(f, fpvirtuals, &p);
TupleExp *tup = new TupleExp(loc, exps);
return tup->semantic(sc);
}
else
assert(0);
}
else if (ident == Id::classInstanceSize)
{
if (dim != 1)
goto Ldimerror;
Object *o = (Object *)args->data[0];
Dsymbol *s = getDsymbol(o);
ClassDeclaration *cd;
if (!s || (cd = s->isClassDeclaration()) == NULL)
{
// error("first argument is not a class");
goto Lfalse;
}
return new IntegerExp(loc, cd->structsize, Type::tsize_t);
}
else if (ident == Id::allMembers || ident == Id::derivedMembers)
{
if (dim != 1)
goto Ldimerror;
Object *o = (Object *)args->data[0];
Dsymbol *s = getDsymbol(o);
ScopeDsymbol *sd;
if (!s)
{
// error("argument has no members");
goto Lfalse;
}
if ((sd = s->isScopeDsymbol()) == NULL)
{
// error("%s %s has no members", s->kind(), s->toChars());
goto Lfalse;
}
Expressions *exps = new Expressions;
while (1)
{ size_t dim = ScopeDsymbol::dim(sd->members);
for (size_t i = 0; i < dim; i++)
{
Dsymbol *sm = ScopeDsymbol::getNth(sd->members, i);
//printf("\t[%i] %s %s\n", i, sm->kind(), sm->toChars());
if (sm->ident)
{
示例8: DtoCreateNestedContext
void DtoCreateNestedContext(FuncDeclaration* fd) {
Logger::println("DtoCreateNestedContext for %s", fd->toChars());
LOG_SCOPE
DtoCreateNestedContextType(fd);
if (nestedCtx == NCArray) {
// construct nested variables array
if (!fd->nestedVars.empty())
{
Logger::println("has nested frame");
// start with adding all enclosing parent frames until a static parent is reached
int nparelems = 0;
if (!fd->isStatic())
{
Dsymbol* par = fd->toParent2();
while (par)
{
if (FuncDeclaration* parfd = par->isFuncDeclaration())
{
nparelems += parfd->nestedVars.size();
// stop at first static
if (parfd->isStatic())
break;
}
else if (par->isClassDeclaration())
{
// nothing needed
}
else
{
break;
}
par = par->toParent2();
}
}
int nelems = fd->nestedVars.size() + nparelems;
// make array type for nested vars
LLType* nestedVarsTy = LLArrayType::get(getVoidPtrType(), nelems);
// alloca it
// FIXME align ?
LLValue* nestedVars = DtoRawAlloca(nestedVarsTy, 0, ".nested_vars");
IrFunction* irfunction = fd->ir.irFunc;
// copy parent frame into beginning
if (nparelems)
{
LLValue* src = irfunction->nestArg;
if (!src)
{
assert(irfunction->thisArg);
assert(fd->isMember2());
LLValue* thisval = DtoLoad(irfunction->thisArg);
ClassDeclaration* cd = fd->isMember2()->isClassDeclaration();
assert(cd);
assert(cd->vthis);
src = DtoLoad(DtoGEPi(thisval, 0,cd->vthis->ir.irField->index, ".vthis"));
} else {
src = DtoLoad(src);
}
DtoMemCpy(nestedVars, src, DtoConstSize_t(nparelems*PTRSIZE),
getABITypeAlign(getVoidPtrType()));
}
// store in IrFunction
irfunction->nestedVar = nestedVars;
// go through all nested vars and assign indices
int idx = nparelems;
for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i)
{
VarDeclaration* vd = *i;
if (!vd->ir.irLocal)
vd->ir.irLocal = new IrLocal(vd);
if (vd->isParameter())
{
Logger::println("nested param: %s", vd->toChars());
LLValue* gep = DtoGEPi(nestedVars, 0, idx);
LLValue* val = DtoBitCast(vd->ir.irLocal->value, getVoidPtrType());
DtoAlignedStore(val, gep);
}
else
{
Logger::println("nested var: %s", vd->toChars());
}
vd->ir.irLocal->nestedIndex = idx++;
}
}
}
else if (nestedCtx == NCHybrid) {
// construct nested variables array
if (!fd->nestedVars.empty())
{
IrFunction* irfunction = fd->ir.irFunc;
//.........这里部分代码省略.........