本文整理汇总了C++中TemplateInstance类的典型用法代码示例。如果您正苦于以下问题:C++ TemplateInstance类的具体用法?C++ TemplateInstance怎么用?C++ TemplateInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TemplateInstance类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Objects
void AggregateDeclaration::semantic3(Scope *sc)
{
//printf("AggregateDeclaration::semantic3(%s)\n", toChars());
if (members)
{
sc = sc->push(this);
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->semantic3(sc);
}
sc->pop();
if (!getRTInfo)
{ // Evaluate: gcinfo!type
Objects *tiargs = new Objects();
tiargs->push(type);
TemplateInstance *ti = new TemplateInstance(loc, Type::rtinfo, tiargs);
ti->semantic(sc);
ti->semantic2(sc);
ti->semantic3(sc);
Dsymbol *s = ti->toAlias();
Expression *e = new DsymbolExp(0, s, 0);
e = e->semantic(ti->tempdecl->scope);
e = e->ctfeInterpret();
getRTInfo = e;
}
}
}
开发者ID:denis-sh,项目名称:dmd,代码行数:29,代码来源:struct.c
示例2: isStructDeclaration
void AggregateDeclaration::semantic3(Scope *sc)
{
//printf("AggregateDeclaration::semantic3(%s) type = %s, errors = %d\n", toChars(), type->toChars(), errors);
if (!members)
return;
StructDeclaration *sd = isStructDeclaration();
if (!sc) // from runDeferredSemantic3 for TypeInfo generation
{
assert(sd);
sd->semanticTypeInfoMembers();
return;
}
Scope *sc2 = sc->push(this);
sc2->stc &= STCsafe | STCtrusted | STCsystem;
sc2->parent = this;
if (isUnionDeclaration())
sc2->inunion = 1;
sc2->protection = Prot(PROTpublic);
sc2->explicitProtection = 0;
sc2->structalign = STRUCTALIGN_DEFAULT;
sc2->userAttribDecl = NULL;
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->semantic3(sc2);
}
sc2->pop();
// don't do it for unused deprecated types
// or error types
if (!getRTInfo && Type::rtinfo &&
(!isDeprecated() || global.params.useDeprecated) &&
(type && type->ty != Terror))
{
// Evaluate: RTinfo!type
Objects *tiargs = new Objects();
tiargs->push(type);
TemplateInstance *ti = new TemplateInstance(loc, Type::rtinfo, tiargs);
ti->semantic(sc);
ti->semantic2(sc);
ti->semantic3(sc);
Dsymbol *s = ti->toAlias();
Expression *e = new DsymbolExp(Loc(), s, 0);
Scope *sc3 = ti->tempdecl->scope->startCTFE();
sc3->tinst = sc->tinst;
e = e->semantic(sc3);
sc3->endCTFE();
e = e->ctfeInterpret();
getRTInfo = e;
}
if (sd)
sd->semanticTypeInfoMembers();
}
开发者ID:hariomrana,项目名称:dmd,代码行数:60,代码来源:struct.c
示例3: toAlias
Dsymbol *Dsymbol::searchX(Loc loc, Scope *sc, RootObject *id)
{
//printf("Dsymbol::searchX(this=%p,%s, ident='%s')\n", this, toChars(), ident->toChars());
Dsymbol *s = toAlias();
Dsymbol *sm;
if (Declaration *d = s->isDeclaration())
{
if (d->inuse)
{
::error(loc, "circular reference to '%s'", d->toPrettyChars());
return NULL;
}
}
switch (id->dyncast())
{
case DYNCAST_IDENTIFIER:
sm = s->search(loc, (Identifier *)id);
break;
case DYNCAST_DSYMBOL:
{
// It's a template instance
//printf("\ttemplate instance id\n");
Dsymbol *st = (Dsymbol *)id;
TemplateInstance *ti = st->isTemplateInstance();
sm = s->search(loc, ti->name);
if (!sm)
{
sm = s->search_correct(ti->name);
if (sm)
error("template identifier '%s' is not a member of '%s %s', did you mean '%s %s'?",
ti->name->toChars(), s->kind(), s->toChars(), sm->kind(), sm->toChars());
else
error("template identifier '%s' is not a member of '%s %s'",
ti->name->toChars(), s->kind(), s->toChars());
return NULL;
}
sm = sm->toAlias();
TemplateDeclaration *td = sm->isTemplateDeclaration();
if (!td)
{
error("%s is not a template, it is a %s", ti->name->toChars(), sm->kind());
return NULL;
}
ti->tempdecl = td;
if (!ti->semanticRun)
ti->semantic(sc);
sm = ti->toAlias();
break;
}
default:
assert(0);
}
return sm;
}
开发者ID:SmorkalovG,项目名称:dmd,代码行数:58,代码来源:dsymbol.c
示例4:
TemplateInstance *Dsymbol::isInstantiated()
{
for (Dsymbol *s = parent; s; s = s->parent)
{
TemplateInstance *ti = s->isTemplateInstance();
if (ti && !ti->isTemplateMixin())
return ti;
}
return NULL;
}
开发者ID:eco,项目名称:dmd,代码行数:10,代码来源:dsymbol.c
示例5: Objects
void AggregateDeclaration::semantic3(Scope *sc)
{
#if IN_LLVM
if (!global.inExtraInliningSemantic)
availableExternally = false;
#endif
//printf("AggregateDeclaration::semantic3(%s)\n", toChars());
if (members)
{
sc = sc->push(this);
sc->parent = this;
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->semantic3(sc);
}
if (StructDeclaration *sd = isStructDeclaration())
{
//if (sd->xeq != NULL) printf("sd = %s xeq @ [%s]\n", sd->toChars(), sd->loc.toChars());
//assert(sd->xeq == NULL);
if (sd->xeq == NULL)
sd->xeq = sd->buildXopEquals(sc);
}
sc = sc->pop();
if (!getRTInfo && Type::rtinfo &&
(!isDeprecated() || global.params.useDeprecated) && // don't do it for unused deprecated types
(type && type->ty != Terror)) // or error types
{ // Evaluate: gcinfo!type
Objects *tiargs = new Objects();
tiargs->push(type);
TemplateInstance *ti = new TemplateInstance(loc, Type::rtinfo, tiargs);
ti->semantic(sc);
ti->semantic2(sc);
ti->semantic3(sc);
Dsymbol *s = ti->toAlias();
Expression *e = new DsymbolExp(Loc(), s, 0);
e = e->ctfeSemantic(ti->tempdecl->scope);
e = e->ctfeInterpret();
getRTInfo = e;
}
}
}
开发者ID:duralog,项目名称:ldc,代码行数:45,代码来源:struct.c
示例6: toAlias
Dsymbol *Dsymbol::searchX(Loc loc, Scope *sc, Identifier *id)
{
//printf("Dsymbol::searchX(this=%p,%s, ident='%s')\n", this, toChars(), ident->toChars());
Dsymbol *s = toAlias();
Dsymbol *sm;
switch (id->dyncast())
{
case DYNCAST_IDENTIFIER:
sm = s->search(loc, id, 0);
break;
case DYNCAST_DSYMBOL:
{ // It's a template instance
//printf("\ttemplate instance id\n");
Dsymbol *st = (Dsymbol *)id;
TemplateInstance *ti = st->isTemplateInstance();
id = ti->name;
sm = s->search(loc, id, 0);
if (!sm)
{ error("template identifier %s is not a member of %s %s",
id->toChars(), s->kind(), s->toChars());
return NULL;
}
sm = sm->toAlias();
TemplateDeclaration *td = sm->isTemplateDeclaration();
if (!td)
{
error("%s is not a template, it is a %s", id->toChars(), sm->kind());
return NULL;
}
ti->tempdecl = td;
if (!ti->semanticRun)
ti->semantic(sc);
sm = ti->toAlias();
break;
}
default:
assert(0);
}
return sm;
}
开发者ID:olgk,项目名称:ldc,代码行数:43,代码来源:dsymbol.c
示例7: Objects
void AggregateDeclaration::generateTypeInfoData(Scope *sc)
{
if (!getRTInfo && Type::rtinfo &&
(!isDeprecated() || global.params.useDeprecated) && // don't do it for unused deprecated types
(type && type->ty != Terror)) // or error types
{ // Evaluate: gcinfo!type
Objects *tiargs = new Objects();
tiargs->push(type);
TemplateInstance *ti = new TemplateInstance(loc, Type::rtinfo, tiargs);
ti->semantic(sc);
ti->semantic2(sc);
ti->semantic3(sc);
Dsymbol *s = ti->toAlias();
Expression *e = new DsymbolExp(Loc(), s, 0);
Scope *sc2 = ti->tempdecl->scope->startCTFE();
sc2->instantiatingModule = sc->instantiatingModule ? sc->instantiatingModule : sc->module;
e = e->semantic(sc2);
sc2->endCTFE();
e = e->ctfeInterpret();
getRTInfo = e;
}
}
开发者ID:rainers,项目名称:dmd,代码行数:23,代码来源:struct.c
示例8: Objects
void AggregateDeclaration::semantic3(Scope *sc)
{
//printf("AggregateDeclaration::semantic3(%s)\n", toChars());
if (members)
{
sc = sc->push(this);
sc->parent = this;
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->semantic3(sc);
}
sc = sc->pop();
if (!getRTInfo && Type::rtinfo &&
(!isDeprecated() || global.params.useDeprecated) && // don't do it for unused deprecated types
(type && type->ty != Terror)) // or error types
{ // Evaluate: gcinfo!type
Objects *tiargs = new Objects();
tiargs->push(type);
TemplateInstance *ti = new TemplateInstance(loc, Type::rtinfo, tiargs);
ti->semantic(sc);
ti->semantic2(sc);
ti->semantic3(sc);
Dsymbol *s = ti->toAlias();
Expression *e = new DsymbolExp(Loc(), s, 0);
Scope *sc = ti->tempdecl->scope->startCTFE();
e = e->semantic(sc);
sc->endCTFE();
e = e->ctfeInterpret();
getRTInfo = e;
}
}
}
开发者ID:ds-dlang,项目名称:dmd,代码行数:36,代码来源:struct.c
示例9: mangleDecl
/******************************************************************************
* isv : for the enclosing auto functions of an inner class/struct type.
* An aggregate type which defined inside auto function, it might
* become Voldemort Type so its object might be returned.
* This flag is necessary due to avoid mutual mangling
* between return type and enclosing scope. See bugzilla 8847.
*/
char *mangleDecl(Declaration *sthis, bool isv)
{
OutBuffer buf;
char *id;
Dsymbol *s;
//printf("::mangleDecl(%s)\n", sthis->toChars());
s = sthis;
do
{
//printf("mangle: s = %p, '%s', parent = %p\n", s, s->toChars(), s->parent);
if (s->getIdent())
{
FuncDeclaration *fd = s->isFuncDeclaration();
if (s != sthis && fd)
{
id = mangleDecl(fd, isv);
buf.prependstring(id);
goto L1;
}
else
{
id = s->ident->toChars();
size_t len = strlen(id);
char tmp[sizeof(len) * 3 + 1];
buf.prependstring(id);
sprintf(tmp, "%d", (int)len);
buf.prependstring(tmp);
}
}
else
buf.prependstring("0");
TemplateInstance *ti = s->isTemplateInstance();
if (ti && !ti->isTemplateMixin())
s = ti->tempdecl->parent;
else
s = s->parent;
} while (s);
// buf.prependstring("_D");
L1:
//printf("deco = '%s'\n", sthis->type->deco ? sthis->type->deco : "null");
//printf("sthis->type = %s\n", sthis->type->toChars());
FuncDeclaration *fd = sthis->isFuncDeclaration();
if (fd && (fd->needThis() || fd->isNested()))
buf.writeByte(Type::needThisPrefix());
if (isv && fd && (fd->inferRetType || getFuncTemplateDecl(fd)))
{
#if DDMD
TypeFunction *tfn = (TypeFunction *)sthis->type->copy();
TypeFunction *tfo = (TypeFunction *)sthis->originalType;
tfn->purity = tfo->purity;
tfn->isnothrow = tfo->isnothrow;
tfn->isproperty = tfo->isproperty;
tfn->isref = fd->storage_class & STCauto ? false : tfo->isref;
tfn->trust = tfo->trust;
tfn->next = NULL; // do not mangle return type
tfn->toDecoBuffer(&buf, 0);
#else
TypeFunction tfn = *(TypeFunction *)sthis->type;
TypeFunction *tfo = (TypeFunction *)sthis->originalType;
tfn.purity = tfo->purity;
tfn.isnothrow = tfo->isnothrow;
tfn.isproperty = tfo->isproperty;
tfn.isref = fd->storage_class & STCauto ? false : tfo->isref;
tfn.trust = tfo->trust;
tfn.next = NULL; // do not mangle return type
tfn.toDecoBuffer(&buf, 0);
#endif
}
else if (sthis->type->deco)
buf.writestring(sthis->type->deco);
else
{
#ifdef DEBUG
if (!fd->inferRetType)
printf("%s\n", fd->toChars());
#endif
assert(fd && fd->inferRetType && fd->type->ty == Tfunction);
TypeFunction *tf = (TypeFunction *)sthis->type;
Type *tn = tf->next;
tf->next = NULL; // do not mangle undetermined return type
tf->toDecoBuffer(&buf, 0);
tf->next = tn;
}
id = buf.extractString();
return id;
}
开发者ID:RoseQuix,项目名称:dmd,代码行数:97,代码来源:mangle.c
示例10: isStructDeclaration
void AggregateDeclaration::semantic3(Scope *sc)
{
//printf("AggregateDeclaration::semantic3(%s)\n", toChars());
if (members)
{
StructDeclaration *sd = isStructDeclaration();
if (!sc) // from runDeferredSemantic3 for TypeInfo generation
goto Lxop;
sc = sc->push(this);
sc->parent = this;
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->semantic3(sc);
}
sc = sc->pop();
if (!getRTInfo && Type::rtinfo &&
(!isDeprecated() || global.params.useDeprecated) && // don't do it for unused deprecated types
(type && type->ty != Terror)) // or error types
{
// Evaluate: RTinfo!type
Objects *tiargs = new Objects();
tiargs->push(type);
TemplateInstance *ti = new TemplateInstance(loc, Type::rtinfo, tiargs);
ti->semantic(sc);
ti->semantic2(sc);
ti->semantic3(sc);
Dsymbol *s = ti->toAlias();
Expression *e = new DsymbolExp(Loc(), s, 0);
Scope *sc2 = ti->tempdecl->scope->startCTFE();
sc2->instantiatingModule = sc->instantiatingModule ? sc->instantiatingModule : sc->module;
e = e->semantic(sc2);
sc2->endCTFE();
e = e->ctfeInterpret();
getRTInfo = e;
}
if (sd)
{
Lxop:
if (sd->xeq &&
sd->xeq->scope &&
sd->xeq->semanticRun < PASSsemantic3done)
{
unsigned errors = global.startGagging();
sd->xeq->semantic3(sd->xeq->scope);
if (global.endGagging(errors))
sd->xeq = sd->xerreq;
}
if (sd->xcmp &&
sd->xcmp->scope &&
sd->xcmp->semanticRun < PASSsemantic3done)
{
unsigned errors = global.startGagging();
sd->xcmp->semantic3(sd->xcmp->scope);
if (global.endGagging(errors))
sd->xcmp = sd->xerrcmp;
}
FuncDeclaration *ftostr = search_toString(sd);
if (ftostr &&
ftostr->scope &&
ftostr->semanticRun < PASSsemantic3done)
{
ftostr->semantic3(ftostr->scope);
}
FuncDeclaration *ftohash = search_toHash(sd);
if (ftohash &&
ftohash->scope &&
ftohash->semanticRun < PASSsemantic3done)
{
ftohash->semantic3(ftohash->scope);
}
}
}
}
开发者ID:Safety0ff,项目名称:dmd,代码行数:82,代码来源:struct.c
示例11: isStructDeclaration
void AggregateDeclaration::semantic3(Scope *sc)
{
//printf("AggregateDeclaration::semantic3(%s) type = %s, errors = %d\n", toChars(), type->toChars(), errors);
if (!members)
return;
StructDeclaration *sd = isStructDeclaration();
if (!sc) // from runDeferredSemantic3 for TypeInfo generation
{
assert(sd);
sd->semanticTypeInfoMembers();
return;
}
Scope *sc2 = sc->push(this);
sc2->stc &= STCsafe | STCtrusted | STCsystem;
sc2->parent = this;
if (isUnionDeclaration())
sc2->inunion = 1;
sc2->protection = Prot(PROTpublic);
sc2->explicitProtection = 0;
sc2->structalign = STRUCTALIGN_DEFAULT;
sc2->userAttribDecl = NULL;
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->semantic3(sc2);
}
sc2->pop();
// don't do it for unused deprecated types
// or error types
if (!getRTInfo && Type::rtinfo &&
(!isDeprecated() || global.params.useDeprecated) &&
(type && type->ty != Terror))
{
// we do not want to report deprecated uses of this type during RTInfo
// generation, so we disable reporting deprecation temporarily
// WARNING: Muting messages during analysis of RTInfo might silently instantiate
// templates that use (other) deprecated types. If these template instances
// are used in other parts of the program later, they will be reused without
// ever producing the deprecation message. The implementation here restricts
// muting to the types that RTInfo is currently generated for.
bool wasmuted = mutedeprecation;
mutedeprecation = true;
// Evaluate: RTinfo!type
Objects *tiargs = new Objects();
tiargs->push(type);
TemplateInstance *ti = new TemplateInstance(loc, Type::rtinfo, tiargs);
ti->semantic(sc);
ti->semantic2(sc);
ti->semantic3(sc);
Dsymbol *s = ti->toAlias();
Expression *e = new DsymbolExp(Loc(), s, 0);
Scope *sc3 = ti->tempdecl->scope->startCTFE();
sc3->tinst = sc->tinst;
e = e->semantic(sc3);
sc3->endCTFE();
e = e->ctfeInterpret();
getRTInfo = e;
mutedeprecation = wasmuted;
}
if (sd)
sd->semanticTypeInfoMembers();
}
开发者ID:nrTQgc,项目名称:ldc,代码行数:72,代码来源:struct.c
注:本文中的TemplateInstance类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论