本文整理汇总了C++中Statements::push方法的典型用法代码示例。如果您正苦于以下问题:C++ Statements::push方法的具体用法?C++ Statements::push怎么用?C++ Statements::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statements
的用法示例。
在下文中一共展示了Statements::push方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompoundStatement
Statement *CompoundStatement::doInlineStatement(InlineDoState *ids)
{
//printf("CompoundStatement::doInlineStatement() %d\n", statements->dim);
Statements *as = new Statements();
as->reserve(statements->dim);
for (size_t i = 0; i < statements->dim; i++)
{ Statement *s = (*statements)[i];
if (s)
{
as->push(s->doInlineStatement(ids));
if (s->isReturnStatement())
break;
/* Check for:
* if (condition)
* return exp1;
* else
* return exp2;
*/
IfStatement *ifs = s->isIfStatement();
if (ifs && ifs->elsebody && ifs->ifbody &&
ifs->ifbody->isReturnStatement() &&
ifs->elsebody->isReturnStatement()
)
break;
}
else
as->push(NULL);
}
return new CompoundStatement(loc, as);
}
示例2: UnrolledLoopStatement
Statement *UnrolledLoopStatement::doInlineStatement(InlineDoState *ids)
{
//printf("UnrolledLoopStatement::doInlineStatement() %d\n", statements->dim);
Statements *as = new Statements();
as->reserve(statements->dim);
for (size_t i = 0; i < statements->dim; i++)
{ Statement *s = (*statements)[i];
if (s)
{
as->push(s->doInlineStatement(ids));
if (ids->foundReturn)
break;
}
else
as->push(NULL);
}
return new UnrolledLoopStatement(loc, as);
}
示例3: IntegerExp
/*****************************************
* Create inclusive postblit for struct by aggregating
* all the postblits in postblits[] with the postblits for
* all the members.
* Note the close similarity with AggregateDeclaration::buildDtor(),
* and the ordering changes (runs forward instead of backwards).
*/
FuncDeclaration *buildPostBlit(StructDeclaration *sd, Scope *sc)
{
//printf("StructDeclaration::buildPostBlit() %s\n", sd->toChars());
StorageClass stc = STCsafe | STCnothrow | STCpure | STCnogc;
Loc declLoc = sd->postblits.dim ? sd->postblits[0]->loc : sd->loc;
Loc loc = Loc(); // internal code should have no loc to prevent coverage
for (size_t i = 0; i < sd->postblits.dim; i++)
{
stc |= sd->postblits[i]->storage_class & STCdisable;
}
Statements *a = NULL;
for (size_t i = 0; i < sd->fields.dim && !(stc & STCdisable); i++)
{
VarDeclaration *v = sd->fields[i];
if (v->storage_class & STCref)
continue;
Type *tv = v->type->baseElemOf();
if (tv->ty != Tstruct || !v->type->size())
continue;
StructDeclaration *sdv = ((TypeStruct *)tv)->sym;
if (!sdv->postblit)
continue;
sdv->postblit->functionSemantic();
stc = mergeFuncAttrs(stc, sdv->postblit);
stc = mergeFuncAttrs(stc, sdv->dtor);
if (stc & STCdisable)
{
a = NULL;
break;
}
if (!a)
a = new Statements();
Expression *ex = new ThisExp(loc);
ex = new DotVarExp(loc, ex, v, 0);
if (v->type->toBasetype()->ty == Tstruct)
{
// this.v.__xpostblit()
// This is a hack so we can call postblits on const/immutable objects.
ex = new AddrExp(loc, ex);
ex = new CastExp(loc, ex, v->type->mutableOf()->pointerTo());
ex = new PtrExp(loc, ex);
if (stc & STCsafe)
stc = (stc & ~STCsafe) | STCtrusted;
ex = new DotVarExp(loc, ex, sdv->postblit, 0);
ex = new CallExp(loc, ex);
}
else
{
// _ArrayPostblit((cast(S*)this.v.ptr)[0 .. n])
// This is a hack so we can call postblits on const/immutable objects.
ex = new DotIdExp(loc, ex, Id::ptr);
ex = new CastExp(loc, ex, sdv->type->pointerTo());
if (stc & STCsafe)
stc = (stc & ~STCsafe) | STCtrusted;
uinteger_t n = v->type->size() / sdv->type->size();
ex = new SliceExp(loc, ex, new IntegerExp(loc, 0, Type::tsize_t),
new IntegerExp(loc, n, Type::tsize_t));
// Prevent redundant bounds check
((SliceExp *)ex)->upperIsInBounds = true;
((SliceExp *)ex)->lowerIsLessThanUpper = true;
ex = new CallExp(loc, new IdentifierExp(loc, Id::_ArrayPostblit), ex);
}
a->push(new ExpStatement(loc, ex)); // combine in forward order
/* Bugzilla 10972: When the following field postblit calls fail,
* this field should be destructed for Exception Safety.
*/
if (!sdv->dtor)
continue;
sdv->dtor->functionSemantic();
ex = new ThisExp(loc);
ex = new DotVarExp(loc, ex, v, 0);
if (v->type->toBasetype()->ty == Tstruct)
{
// this.v.__xdtor()
// This is a hack so we can call destructors on const/immutable objects.
ex = new AddrExp(loc, ex);
ex = new CastExp(loc, ex, v->type->mutableOf()->pointerTo());
ex = new PtrExp(loc, ex);
if (stc & STCsafe)
stc = (stc & ~STCsafe) | STCtrusted;
//.........这里部分代码省略.........
示例4: printf
Expression *FuncDeclaration::expandInline(InlineScanState *iss,
Expression *eret, Expression *ethis, Expressions *arguments, Statement **ps)
{
InlineDoState ids;
Expression *e = NULL;
Statements *as = NULL;
TypeFunction *tf = (TypeFunction*)type;
#if LOG || CANINLINE_LOG
printf("FuncDeclaration::expandInline('%s')\n", toChars());
#endif
memset(&ids, 0, sizeof(ids));
ids.parent = iss->fd;
ids.fd = this;
if (ps)
as = new Statements();
VarDeclaration *vret = NULL;
if (eret)
{
if (eret->op == TOKvar)
{
vret = ((VarExp *)eret)->var->isVarDeclaration();
assert(!(vret->storage_class & (STCout | STCref)));
}
else
{
/* Inlining:
* this.field = foo(); // inside constructor
*/
vret = new VarDeclaration(loc, eret->type, Lexer::uniqueId("_satmp"), NULL);
vret->storage_class |= STCtemp | STCforeach | STCref;
vret->linkage = LINKd;
vret->parent = iss->fd;
Expression *de;
de = new DeclarationExp(loc, vret);
de->type = Type::tvoid;
e = Expression::combine(e, de);
Expression *ex;
ex = new VarExp(loc, vret);
ex->type = vret->type;
ex = new ConstructExp(loc, ex, eret);
ex->type = vret->type;
e = Expression::combine(e, ex);
}
}
// Set up vthis
if (ethis)
{
VarDeclaration *vthis;
ExpInitializer *ei;
VarExp *ve;
if (ethis->type->ty == Tpointer)
{ Type *t = ethis->type->nextOf();
ethis = new PtrExp(ethis->loc, ethis);
ethis->type = t;
}
ei = new ExpInitializer(ethis->loc, ethis);
vthis = new VarDeclaration(ethis->loc, ethis->type, Id::This, ei);
if (ethis->type->ty != Tclass)
vthis->storage_class = STCref;
else
vthis->storage_class = STCin;
vthis->linkage = LINKd;
vthis->parent = iss->fd;
ve = new VarExp(vthis->loc, vthis);
ve->type = vthis->type;
ei->exp = new AssignExp(vthis->loc, ve, ethis);
ei->exp->type = ve->type;
if (ethis->type->ty != Tclass)
{ /* This is a reference initialization, not a simple assignment.
*/
ei->exp->op = TOKconstruct;
}
ids.vthis = vthis;
}
// Set up parameters
if (ethis)
{
Expression *de = new DeclarationExp(Loc(), ids.vthis);
de->type = Type::tvoid;
e = Expression::combine(e, de);
}
if (!ps && nrvo_var)
{
if (vret)
{
ids.from.push(nrvo_var);
//.........这里部分代码省略.........
示例5: printf
Expression *FuncDeclaration::expandInline(InlineScanState *iss, Expression *ethis, Expressions *arguments, Statement **ps)
{
InlineDoState ids;
DeclarationExp *de;
Expression *e = NULL;
Statements *as = NULL;
#if LOG || CANINLINE_LOG
printf("FuncDeclaration::expandInline('%s')\n", toChars());
#endif
memset(&ids, 0, sizeof(ids));
ids.parent = iss->fd;
ids.fd = this;
if (ps)
as = new Statements();
// Set up vthis
if (ethis)
{
VarDeclaration *vthis;
ExpInitializer *ei;
VarExp *ve;
#if STRUCTTHISREF
if (ethis->type->ty == Tpointer)
{ Type *t = ethis->type->nextOf();
ethis = new PtrExp(ethis->loc, ethis);
ethis->type = t;
}
ei = new ExpInitializer(ethis->loc, ethis);
vthis = new VarDeclaration(ethis->loc, ethis->type, Id::This, ei);
if (ethis->type->ty != Tclass)
vthis->storage_class = STCref;
else
vthis->storage_class = STCin;
#else
if (ethis->type->ty != Tclass && ethis->type->ty != Tpointer)
{
ethis = ethis->addressOf(NULL);
}
ei = new ExpInitializer(ethis->loc, ethis);
vthis = new VarDeclaration(ethis->loc, ethis->type, Id::This, ei);
vthis->storage_class = STCin;
#endif
vthis->linkage = LINKd;
vthis->parent = iss->fd;
ve = new VarExp(vthis->loc, vthis);
ve->type = vthis->type;
ei->exp = new AssignExp(vthis->loc, ve, ethis);
ei->exp->type = ve->type;
#if STRUCTTHISREF
if (ethis->type->ty != Tclass)
{ /* This is a reference initialization, not a simple assignment.
*/
ei->exp->op = TOKconstruct;
}
#endif
ids.vthis = vthis;
}
// Set up parameters
if (ethis)
{
e = new DeclarationExp(0, ids.vthis);
e->type = Type::tvoid;
if (as)
as->push(new ExpStatement(e->loc, e));
}
if (arguments && arguments->dim)
{
assert(parameters->dim == arguments->dim);
for (size_t i = 0; i < arguments->dim; i++)
{
VarDeclaration *vfrom = parameters->tdata()[i];
VarDeclaration *vto;
Expression *arg = arguments->tdata()[i];
ExpInitializer *ei;
VarExp *ve;
ei = new ExpInitializer(arg->loc, arg);
vto = new VarDeclaration(vfrom->loc, vfrom->type, vfrom->ident, ei);
vto->storage_class |= vfrom->storage_class & (STCin | STCout | STClazy | STCref);
vto->linkage = vfrom->linkage;
vto->parent = iss->fd;
//printf("vto = '%s', vto->storage_class = x%x\n", vto->toChars(), vto->storage_class);
//printf("vto->parent = '%s'\n", iss->fd->toChars());
ve = new VarExp(vto->loc, vto);
//ve->type = vto->type;
//.........这里部分代码省略.........