本文整理汇总了C++中Dsymbol::isTemplateInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ Dsymbol::isTemplateInstance方法的具体用法?C++ Dsymbol::isTemplateInstance怎么用?C++ Dsymbol::isTemplateInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dsymbol
的用法示例。
在下文中一共展示了Dsymbol::isTemplateInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toObjFile
void FuncDeclaration::toObjFile(int multiobj)
{
Symbol *senter;
Symbol *sexit;
FuncDeclaration *func = this;
ClassDeclaration *cd = func->parent->isClassDeclaration();
int reverse;
int i;
int has_arguments;
//printf("FuncDeclaration::toObjFile(%p, %s.%s)\n", func, parent->toChars(), func->toChars());
//if (type) printf("type = %s\n", func->type->toChars());
#if 0
//printf("line = %d\n",func->getWhere() / LINEINC);
EEcontext *ee = env->getEEcontext();
if (ee->EEcompile == 2)
{
if (ee->EElinnum < (func->getWhere() / LINEINC) ||
ee->EElinnum > (func->endwhere / LINEINC)
)
return; // don't compile this function
ee->EEfunc = func->toSymbol();
}
#endif
if (semanticRun >= PASSobj) // if toObjFile() already run
return;
// If errors occurred compiling it, such as bugzilla 6118
if (type && type->ty == Tfunction && ((TypeFunction *)type)->next->ty == Terror)
return;
if (!func->fbody)
{
return;
}
if (func->isUnitTestDeclaration() && !global.params.useUnitTests)
return;
if (multiobj && !isStaticDtorDeclaration() && !isStaticCtorDeclaration())
{ obj_append(this);
return;
}
assert(semanticRun == PASSsemantic3done);
semanticRun = PASSobj;
if (global.params.verbose)
printf("function %s\n",func->toChars());
Symbol *s = func->toSymbol();
func_t *f = s->Sfunc;
#if TARGET_WINDOS
/* This is done so that the 'this' pointer on the stack is the same
* distance away from the function parameters, so that an overriding
* function can call the nested fdensure or fdrequire of its overridden function
* and the stack offsets are the same.
*/
if (isVirtual() && (fensure || frequire))
f->Fflags3 |= Ffakeeh;
#endif
#if TARGET_OSX
s->Sclass = SCcomdat;
#else
s->Sclass = SCglobal;
#endif
for (Dsymbol *p = parent; p; p = p->parent)
{
if (p->isTemplateInstance())
{
s->Sclass = SCcomdat;
break;
}
}
/* Vector operations should be comdat's
*/
if (isArrayOp)
s->Sclass = SCcomdat;
if (isNested())
{
// if (!(config.flags3 & CFG3pic))
// s->Sclass = SCstatic;
f->Fflags3 |= Fnested;
}
else
{
const char *libname = (global.params.symdebug)
? global.params.debuglibname
: global.params.defaultlibname;
// Pull in RTL startup code
if (func->isMain())
{ objextdef("_main");
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
obj_ehsections(); // initialize exception handling sections
#endif
//.........这里部分代码省略.........
示例2: FuncDeclaration_toObjFile
//.........这里部分代码省略.........
if (global.params.verbose)
fprintf(global.stdmsg, "function %s\n", fd->toPrettyChars());
Symbol *s = toSymbol(fd);
func_t *f = s->Sfunc;
// tunnel type of "this" to debug info generation
if (AggregateDeclaration* ad = fd->parent->isAggregateDeclaration())
{
::type* t = Type_toCtype(ad->getType());
if (cd)
t = t->Tnext; // skip reference
f->Fclass = (Classsym *)t;
}
/* This is done so that the 'this' pointer on the stack is the same
* distance away from the function parameters, so that an overriding
* function can call the nested fdensure or fdrequire of its overridden function
* and the stack offsets are the same.
*/
if (fd->isVirtual() && (fd->fensure || fd->frequire))
f->Fflags3 |= Ffakeeh;
#if TARGET_OSX
if(strncmp(s->Sident, "__imgInit", 9) == 0 || strncmp(s->Sident, "__imgTerm", 9) == 0)
s->Sclass = SCglobal;
else
s->Sclass = SCcomdat;
#else
s->Sclass = SCglobal;
#endif
for (Dsymbol *p = fd->parent; p; p = p->parent)
{
if (p->isTemplateInstance())
{
s->Sclass = SCcomdat;
break;
}
}
/* Vector operations should be comdat's
*/
if (fd->isArrayOp)
s->Sclass = SCcomdat;
if (fd->inlinedNestedCallees)
{
/* Bugzilla 15333: If fd contains inlined expressions that come from
* nested function bodies, the enclosing of the functions must be
* generated first, in order to calculate correct frame pointer offset.
*/
for (size_t i = 0; i < fd->inlinedNestedCallees->dim; i++)
{
FuncDeclaration *f = (*fd->inlinedNestedCallees)[i];
FuncDeclaration *fp = f->toParent2()->isFuncDeclaration();;
if (fp && fp->semanticRun < PASSobj)
{
toObjFile(fp, multiobj);
}
}
}
if (fd->isNested())
{
//if (!(config.flags3 & CFG3pic))
// s->Sclass = SCstatic;
示例3: semantic
//.........这里部分代码省略.........
{
}
else if (storage_class & STCctfe)
{
}
else
{
AggregateDeclaration *aad = sc->anonAgg;
if (!aad)
aad = parent->isAggregateDeclaration();
if (aad)
{
#if DMDV2
assert(!(storage_class & (STCextern | STCstatic | STCtls | STCgshared)));
if (storage_class & (STCconst | STCimmutable) && init)
{
if (!type->toBasetype()->isTypeBasic())
storage_class |= STCstatic;
}
else
#endif
aad->addField(sc, this);
}
InterfaceDeclaration *id = parent->isInterfaceDeclaration();
if (id)
{
error("field not allowed in interface");
}
/* Templates cannot add fields to aggregates
*/
TemplateInstance *ti = parent->isTemplateInstance();
if (ti)
{
// Take care of nested templates
while (1)
{
TemplateInstance *ti2 = ti->tempdecl->parent->isTemplateInstance();
if (!ti2)
break;
ti = ti2;
}
// If it's a member template
AggregateDeclaration *ad = ti->tempdecl->isMember();
if (ad && storage_class != STCundefined)
{
error("cannot use template to add field to aggregate '%s'", ad->toChars());
}
}
}
#if DMDV2
if ((storage_class & (STCref | STCparameter | STCforeach)) == STCref &&
ident != Id::This)
{
error("only parameters or foreach declarations can be ref");
}
#endif
if (type->isauto() && !noauto)
{
if (storage_class & (STCfield | STCout | STCref | STCstatic) || !fd)
{
示例4: toObjFile
void FuncDeclaration::toObjFile(int multiobj)
{
FuncDeclaration *func = this;
ClassDeclaration *cd = func->parent->isClassDeclaration();
int reverse;
int has_arguments;
//printf("FuncDeclaration::toObjFile(%p, %s.%s)\n", func, parent->toChars(), func->toChars());
//if (type) printf("type = %s\n", func->type->toChars());
#if 0
//printf("line = %d\n",func->getWhere() / LINEINC);
EEcontext *ee = env->getEEcontext();
if (ee->EEcompile == 2)
{
if (ee->EElinnum < (func->getWhere() / LINEINC) ||
ee->EElinnum > (func->endwhere / LINEINC)
)
return; // don't compile this function
ee->EEfunc = func->toSymbol();
}
#endif
if (semanticRun >= PASSobj) // if toObjFile() already run
return;
// If errors occurred compiling it, such as bugzilla 6118
if (type && type->ty == Tfunction && ((TypeFunction *)type)->next->ty == Terror)
return;
if (!func->fbody)
{
return;
}
if (func->isUnitTestDeclaration() && !global.params.useUnitTests)
return;
if (multiobj && !isStaticDtorDeclaration() && !isStaticCtorDeclaration())
{ obj_append(this);
return;
}
if (semanticRun == PASSsemanticdone)
{
/* What happened is this function failed semantic3() with errors,
* but the errors were gagged.
* Try to reproduce those errors, and then fail.
*/
error("errors compiling the function");
return;
}
assert(semanticRun == PASSsemantic3done);
semanticRun = PASSobj;
if (global.params.verbose)
printf("function %s\n",func->toPrettyChars());
Symbol *s = func->toSymbol();
func_t *f = s->Sfunc;
#if TARGET_WINDOS
/* This is done so that the 'this' pointer on the stack is the same
* distance away from the function parameters, so that an overriding
* function can call the nested fdensure or fdrequire of its overridden function
* and the stack offsets are the same.
*/
if (isVirtual() && (fensure || frequire))
f->Fflags3 |= Ffakeeh;
#endif
#if TARGET_OSX
s->Sclass = SCcomdat;
#else
s->Sclass = SCglobal;
#endif
for (Dsymbol *p = parent; p; p = p->parent)
{
if (p->isTemplateInstance())
{
s->Sclass = SCcomdat;
break;
}
}
/* Vector operations should be comdat's
*/
if (isArrayOp)
s->Sclass = SCcomdat;
if (isNested())
{
// if (!(config.flags3 & CFG3pic))
// s->Sclass = SCstatic;
f->Fflags3 |= Fnested;
/* The enclosing function must have its code generated first,
* so we know things like where its local symbols are stored.
*/
FuncDeclaration *fdp = toAliasFunc()->toParent2()->isFuncDeclaration();
// Bug 8016 - only include the function if it is a template instance
Dsymbol * owner = NULL;
//.........这里部分代码省略.........
示例5: visit
void visit(VarDeclaration *vd)
{
//printf("VarDeclaration::toObjFile(%p '%s' type=%s) protection %d\n", vd, vd->toChars(), vd->type->toChars(), vd->protection);
//printf("\talign = %d\n", vd->alignment);
if (vd->type->ty == Terror)
{
vd->error("had semantic errors when compiling");
return;
}
if (vd->aliassym)
{
visitNoMultiObj(vd->toAlias());
return;
}
// Do not store variables we cannot take the address of
if (!vd->canTakeAddressOf())
{
return;
}
if (!vd->isDataseg() || vd->storage_class & STCextern)
return;
Symbol *s = toSymbol(vd);
unsigned sz = vd->type->size();
Dsymbol *parent = vd->toParent();
s->Sclass = SCglobal;
if(strncmp(s->Sident, "__didInit", 9) == 0 || strncmp(s->Sident, "__imgInfo", 9) == 0)
s->Sclass = SCcomdat;
do
{
/* Global template data members need to be in comdat's
* in case multiple .obj files instantiate the same
* template with the same types.
*/
if (parent->isTemplateInstance() && !parent->isTemplateMixin())
{
s->Sclass = SCcomdat;
break;
}
parent = parent->parent;
} while (parent);
s->Sfl = FLdata;
if (config.objfmt == OBJ_MACH && I64 && (s->ty() & mTYLINK) == mTYthread)
{
DtBuilder dtb;
tlsToDt(vd, s, dtb);
s->Sdt = dtb.finish();
}
else if (vd->_init)
{
DtBuilder dtb;
initializerToDt(vd, dtb);
s->Sdt = dtb.finish();
}
else
{
DtBuilder dtb;
Type_toDt(vd->type, &dtb);
s->Sdt = dtb.finish();
}
// See if we can convert a comdat to a comdef,
// which saves on exe file space.
if (s->Sclass == SCcomdat &&
s->Sdt &&
dtallzeros(s->Sdt) &&
!vd->isThreadlocal())
{
s->Sclass = SCglobal;
dt2common(&s->Sdt);
}
if (!sz && vd->type->toBasetype()->ty != Tsarray)
assert(0); // this shouldn't be possible
if (sz || objmod->allowZeroSize())
{
outdata(s);
if (vd->isExport())
objmod->export_symbol(s, 0);
}
}
示例6: toObjFile
void VarDeclaration::toObjFile(bool multiobj)
{
Symbol *s;
unsigned sz;
Dsymbol *parent;
//printf("VarDeclaration::toObjFile(%p '%s' type=%s) protection %d\n", this, toChars(), type->toChars(), protection);
//printf("\talign = %d\n", alignment);
if (type->ty == Terror)
{ error("had semantic errors when compiling");
return;
}
if (aliassym)
{ toAlias()->toObjFile(0);
return;
}
// Do not store variables we cannot take the address of
if (!canTakeAddressOf())
{
return;
}
if (isDataseg() && !(storage_class & STCextern))
{
s = toSymbol(this);
sz = type->size();
parent = this->toParent();
{
s->Sclass = SCglobal;
do
{
/* Global template data members need to be in comdat's
* in case multiple .obj files instantiate the same
* template with the same types.
*/
if (parent->isTemplateInstance() && !parent->isTemplateMixin())
{
s->Sclass = SCcomdat;
break;
}
parent = parent->parent;
} while (parent);
}
s->Sfl = FLdata;
if (init)
{
s->Sdt = Initializer_toDt(init);
// Look for static array that is block initialized
Type *tb;
ExpInitializer *ie = init->isExpInitializer();
tb = type->toBasetype();
if (tb->ty == Tsarray && ie &&
!tb->nextOf()->equals(ie->exp->type->toBasetype()->nextOf()) &&
ie->exp->implicitConvTo(tb->nextOf())
)
{
size_t dim = ((TypeSArray *)tb)->dim->toInteger();
// Duplicate Sdt 'dim-1' times, as we already have the first one
dt_t **pdt = &s->Sdt;
while (--dim > 0)
{
pdt = ie->exp->toDt(pdt);
}
}
}
else if (storage_class & STCextern)
{
s->Sclass = SCextern;
s->Sfl = FLextern;
s->Sdt = NULL;
// BUG: if isExport(), shouldn't we make it dllimport?
return;
}
else
{
Type_toDt(type, &s->Sdt);
}
dt_optimize(s->Sdt);
// See if we can convert a comdat to a comdef,
// which saves on exe file space.
if (s->Sclass == SCcomdat &&
s->Sdt &&
dtallzeros(s->Sdt) &&
!isThreadlocal())
{
s->Sclass = SCglobal;
dt2common(&s->Sdt);
}
if (!sz && type->toBasetype()->ty != Tsarray)
//.........这里部分代码省略.........