本文整理汇总了C++中Objects::push方法的典型用法代码示例。如果您正苦于以下问题:C++ Objects::push方法的具体用法?C++ Objects::push怎么用?C++ Objects::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Objects
的用法示例。
在下文中一共展示了Objects::push方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
/*******************************************
* Helper function to turn operator into template argument list
*/
Objects *opToArg(Scope *sc, enum TOK op)
{
/* Remove the = from op=
*/
switch (op)
{
case TOKaddass: op = TOKadd; break;
case TOKminass: op = TOKmin; break;
case TOKmulass: op = TOKmul; break;
case TOKdivass: op = TOKdiv; break;
case TOKmodass: op = TOKmod; break;
case TOKandass: op = TOKand; break;
case TOKorass: op = TOKor; break;
case TOKxorass: op = TOKxor; break;
case TOKshlass: op = TOKshl; break;
case TOKshrass: op = TOKshr; break;
case TOKushrass: op = TOKushr; break;
case TOKcatass: op = TOKcat; break;
case TOKpowass: op = TOKpow; break;
}
Expression *e = new StringExp(0, (char *)Token::toChars(op));
e = e->semantic(sc);
Objects *targsi = new Objects();
targsi->push(e);
return targsi;
}
示例2: 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;
}
}
}
示例3: 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();
}
示例4: 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;
}
}
}
示例5: build_overload
/***********************************************
* This is mostly the same as UnaryExp::op_overload(), but has
* a different rewrite.
*/
Expression *CastExp::op_overload(Scope *sc)
{
//printf("CastExp::op_overload() (%s)\n", toChars());
AggregateDeclaration *ad = isAggregate(e1->type);
if (ad)
{
Dsymbol *fd = NULL;
/* Rewrite as:
* e1.opCast!(T)();
*/
fd = search_function(ad, Id::cast);
if (fd)
{
#if 1 // Backwards compatibility with D1 if opCast is a function, not a template
if (fd->isFuncDeclaration())
{ // Rewrite as: e1.opCast()
return build_overload(loc, sc, e1, NULL, fd);
}
#endif
Objects *targsi = new Objects();
targsi->push(to);
Expression *e = new DotTemplateInstanceExp(loc, e1, fd->ident, targsi);
e = new CallExp(loc, e);
e = e->semantic(sc);
return e;
}
// Didn't find it. Forward to aliasthis
if (ad->aliasthis)
{
/* Rewrite op(e1) as:
* op(e1.aliasthis)
*/
Expression *e1 = new DotIdExp(loc, this->e1, ad->aliasthis->ident);
Expression *e = copy();
((UnaExp *)e)->e1 = e1;
e = e->trySemantic(sc);
return e;
}
}
return NULL;
}
示例6: generateTypeInfoData
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;
}
}
示例7: 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;
}
}
}
示例8: if
//.........这里部分代码省略.........
*/
if (!*pvar) // if not already initialized
{ /* Create variable v and set it to the value of $
*/
VarDeclaration *v;
Type *t;
if (ce->op == TOKtuple)
{ /* It is for an expression tuple, so the
* length will be a const.
*/
Expression *e = new IntegerExp(Loc(), ((TupleExp *)ce)->exps->dim, Type::tsize_t);
v = new VarDeclaration(loc, Type::tsize_t, Id::dollar, new ExpInitializer(Loc(), e));
v->storage_class |= STCstatic | STCconst;
}
else if (ce->type && (t = ce->type->toBasetype()) != NULL &&
(t->ty == Tstruct || t->ty == Tclass))
{ // Look for opDollar
assert(exp->op == TOKarray || exp->op == TOKslice);
AggregateDeclaration *ad = NULL;
if (t->ty == Tclass)
{
ad = ((TypeClass *)t)->sym;
}
else if (t->ty == Tstruct)
{
ad = ((TypeStruct *)t)->sym;
}
assert(ad);
Dsymbol *s = ad->search(loc, Id::opDollar, 0);
if (!s) // no dollar exists -- search in higher scope
return NULL;
s = s->toAlias();
Expression *e = NULL;
// Check for multi-dimensional opDollar(dim) template.
if (TemplateDeclaration *td = s->isTemplateDeclaration())
{
dinteger_t dim;
if (exp->op == TOKarray)
{
dim = ((ArrayExp *)exp)->currentDimension;
}
else if (exp->op == TOKslice)
{
dim = 0; // slices are currently always one-dimensional
}
Objects *tdargs = new Objects();
Expression *edim = new IntegerExp(Loc(), dim, Type::tsize_t);
edim = edim->semantic(sc);
tdargs->push(edim);
//TemplateInstance *ti = new TemplateInstance(loc, td, tdargs);
//ti->semantic(sc);
e = new DotTemplateInstanceExp(loc, ce, td->ident, tdargs);
}
else
{ /* opDollar exists, but it's not a template.
* This is acceptable ONLY for single-dimension indexing.
* Note that it's impossible to have both template & function opDollar,
* because both take no arguments.
*/
if (exp->op == TOKarray && ((ArrayExp *)exp)->arguments->dim != 1)
{
exp->error("%s only defines opDollar for one dimension", ad->toChars());
return NULL;
}
Declaration *d = s->isDeclaration();
assert(d);
e = new DotVarExp(loc, ce, d);
}
e = e->semantic(sc);
if (!e->type)
exp->error("%s has no value", e->toChars());
t = e->type->toBasetype();
if (t && t->ty == Tfunction)
e = new CallExp(e->loc, e);
v = new VarDeclaration(loc, NULL, Id::dollar, new ExpInitializer(Loc(), e));
}
else
{ /* For arrays, $ will either be a compile-time constant
* (in which case its value in set during constant-folding),
* or a variable (in which case an expression is created in
* toir.c).
*/
VoidInitializer *e = new VoidInitializer(Loc());
e->type = Type::tsize_t;
v = new VarDeclaration(loc, Type::tsize_t, Id::dollar, e);
v->storage_class |= STCctfe; // it's never a true static variable
}
*pvar = v;
}
(*pvar)->semantic(sc);
return (*pvar);
}
return NULL;
}
示例9: 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);
}
}
}
}
示例10: store
void store(RootObject *p)
{
//printf("push %s\n", p ? p->toChars() : NULL);
components.push(p);
}
示例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();
}