本文整理汇总了C++中ExpressionPtrVec::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ ExpressionPtrVec::push_back方法的具体用法?C++ ExpressionPtrVec::push_back怎么用?C++ ExpressionPtrVec::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionPtrVec
的用法示例。
在下文中一共展示了ExpressionPtrVec::push_back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getConcatList
int BinaryOpExpression::getConcatList(ExpressionPtrVec &ev, ExpressionPtr exp,
bool &hasVoid) {
if (!exp->hasCPPTemp()) {
if (exp->is(Expression::KindOfUnaryOpExpression)) {
UnaryOpExpressionPtr u = static_pointer_cast<UnaryOpExpression>(exp);
if (u->getOp() == '(') {
return getConcatList(ev, u->getExpression(), hasVoid);
}
} else if (exp->is(Expression::KindOfBinaryOpExpression)) {
BinaryOpExpressionPtr b = static_pointer_cast<BinaryOpExpression>(exp);
if (b->getOp() == '.') {
return getConcatList(ev, b->getExp1(), hasVoid) +
getConcatList(ev, b->getExp2(), hasVoid);
}
} else if (exp->is(Expression::KindOfEncapsListExpression)) {
EncapsListExpressionPtr e =
static_pointer_cast<EncapsListExpression>(exp);
if (e->getType() != '`') {
ExpressionListPtr el = e->getExpressions();
int num = 0;
for (int i = 0, s = el->getCount(); i < s; i++) {
ExpressionPtr exp = (*el)[i];
num += getConcatList(ev, exp, hasVoid);
}
return num;
}
}
}
ev.push_back(exp);
bool isVoid = !exp->getActualType();
hasVoid |= isVoid;
return isVoid ? 0 : 1;
}
示例2: getConcatList
int BinaryOpExpression::getConcatList(ExpressionPtrVec &ev, ExpressionPtr exp,
bool &hasVoid) {
if (!exp->hasCPPTemp()) {
if (exp->is(Expression::KindOfUnaryOpExpression)) {
UnaryOpExpressionPtr u = static_pointer_cast<UnaryOpExpression>(exp);
if (u->getOp() == '(') {
return getConcatList(ev, u->getExpression(), hasVoid);
}
} else if (exp->is(Expression::KindOfBinaryOpExpression)) {
BinaryOpExpressionPtr b = static_pointer_cast<BinaryOpExpression>(exp);
if (b->getOp() == '.') {
if (b->getExp1()->is(Expression::KindOfSimpleVariable) &&
b->getExp1()->isLocalExprAltered() &&
!b->getExp1()->hasCPPTemp() &&
b->getExp2()->hasEffect() &&
!b->getExp2()->hasCPPTemp()) {
/*
In this case, the simple variable must be evaluated
after b->getExp2(). But when we output a concat list we
explicitly order the expressions from left to right.
*/
} else {
return getConcatList(ev, b->getExp1(), hasVoid) +
getConcatList(ev, b->getExp2(), hasVoid);
}
}
} else if (exp->is(Expression::KindOfEncapsListExpression)) {
EncapsListExpressionPtr e =
static_pointer_cast<EncapsListExpression>(exp);
if (e->getType() != '`') {
ExpressionListPtr el = e->getExpressions();
int num = 0;
for (int i = 0, s = el->getCount(); i < s; i++) {
ExpressionPtr exp = (*el)[i];
num += getConcatList(ev, exp, hasVoid);
}
return num;
}
}
} else if (!exp->getActualType()) {
return 0;
}
ev.push_back(exp);
bool isVoid = !exp->getActualType();
hasVoid |= isVoid;
return isVoid ? 0 : 1;
}
示例3: preOutputCPP
bool BinaryOpExpression::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
if (isOpEqual()) return Expression::preOutputCPP(cg, ar, state);
bool effect2 = m_exp2->hasEffect();
const char *prefix = 0;
if (effect2 || m_exp1->hasEffect()) {
ExpressionPtr self = static_pointer_cast<Expression>(shared_from_this());
ExpressionPtrVec ev;
bool hasVoid = false;
int numConcat = 0;
bool ok = false;
if (m_op == '.') {
numConcat = getConcatList(ev, self, hasVoid);
ok = hasVoid ||
(numConcat > MAX_CONCAT_ARGS &&
(!Option::GenConcat ||
cg.getOutput() == CodeGenerator::SystemCPP));
} else if (effect2 && m_op == T_CONCAT_EQUAL) {
prefix = stringBufferPrefix(cg, ar, m_exp1);
ok = prefix;
if (!ok) {
if (m_exp1->is(KindOfSimpleVariable)) {
ok = true;
ev.push_back(m_exp1);
numConcat++;
}
}
numConcat += getConcatList(ev, m_exp2, hasVoid);
}
if (ok) {
if (!cg.inExpression()) return true;
cg.wrapExpressionBegin();
std::string buf;
if (prefix) {
SimpleVariablePtr sv(static_pointer_cast<SimpleVariable>(m_exp1));
buf = stringBufferName(Option::TempPrefix, prefix,
sv->getName().c_str());
m_cppTemp = "/**/";
} else if (numConcat) {
buf = m_cppTemp = genCPPTemp(cg, ar);
buf += "_buf";
cg_printf("StringBuffer %s;\n", buf.c_str());
} else {
m_cppTemp = "\"\"";
}
for (size_t i = 0; i < ev.size(); i++) {
ExpressionPtr exp = ev[i];
bool is_void = !exp->getActualType();
exp->preOutputCPP(cg, ar, 0);
if (!is_void) {
cg_printf("%s.append(", buf.c_str());
outputStringExpr(cg, ar, exp, true);
cg_printf(")");
} else {
exp->outputCPPUnneeded(cg, ar);
}
cg_printf(";\n");
}
if (numConcat && !prefix) {
cg_printf("CStrRef %s(%s.detach());\n",
m_cppTemp.c_str(), buf.c_str());
if (m_op == T_CONCAT_EQUAL) {
m_exp1->outputCPP(cg, ar);
cg_printf(" = %s;\n", m_cppTemp.c_str());
}
}
return true;
}
}
if (!isShortCircuitOperator()) {
return Expression::preOutputCPP(cg, ar, state);
}
if (!effect2) {
return m_exp1->preOutputCPP(cg, ar, state);
}
bool fix_e1 = m_exp1->preOutputCPP(cg, ar, 0);
if (!cg.inExpression()) {
return fix_e1 || m_exp2->preOutputCPP(cg, ar, 0);
}
cg.setInExpression(false);
bool fix_e2 = m_exp2->preOutputCPP(cg, ar, 0);
cg.setInExpression(true);
if (fix_e2) {
cg.wrapExpressionBegin();
std::string tmp = genCPPTemp(cg, ar);
cg_printf("bool %s = (", tmp.c_str());
m_exp1->outputCPP(cg, ar);
cg_printf(");\n");
cg_indentBegin("if (%s%s) {\n",
m_op == T_LOGICAL_OR || m_op == T_BOOLEAN_OR ? "!" : "",
tmp.c_str());
m_exp2->preOutputCPP(cg, ar, 0);
//.........这里部分代码省略.........