本文整理汇总了C++中ExpressionPtr::outputCPPExistTest方法的典型用法代码示例。如果您正苦于以下问题:C++ ExpressionPtr::outputCPPExistTest方法的具体用法?C++ ExpressionPtr::outputCPPExistTest怎么用?C++ ExpressionPtr::outputCPPExistTest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionPtr
的用法示例。
在下文中一共展示了ExpressionPtr::outputCPPExistTest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: preOutputCPP
bool UnaryOpExpression::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
if (m_op == T_ISSET && m_exp && m_exp->is(Expression::KindOfExpressionList)) {
ExpressionListPtr exps = dynamic_pointer_cast<ExpressionList>(m_exp);
int count = exps->getCount();
if (count > 1) {
bool fix_e1 = (*exps)[0]->preOutputCPP(cg, ar, 0);
bool inExpression = ar->inExpression();
ar->setInExpression(false);
bool fix_en = false;
for (int i = 1; i < count; i++) {
if ((*exps)[i]->preOutputCPP(cg, ar, 0)) {
fix_en = true;
break;
}
}
ar->setInExpression(inExpression);
if (inExpression && fix_en) {
ar->wrapExpressionBegin(cg);
std::string tmp = genCPPTemp(cg, ar);
cg.printf("bool %s = (", tmp.c_str());
(*exps)[0]->outputCPPExistTest(cg, ar, m_op);
cg.printf(");\n");
for (int i = 1; i < count; i++) {
cg.indentBegin("if (%s) {\n", tmp.c_str());
ExpressionPtr e = (*exps)[i];
e->preOutputCPP(cg, ar, 0);
cg.printf("%s = (", tmp.c_str());
e->outputCPPExistTest(cg, ar, m_op);
cg.printf(");\n");
}
for (int i = 1; i < count; i++) {
cg.indentEnd("}\n");
}
m_cppTemp = tmp;
} else if (state & FixOrder) {
preOutputStash(cg, ar, state);
fix_e1 = true;
}
return fix_e1 || fix_en;
}
}
return Expression::preOutputCPP(cg, ar, state);
}
示例2: preOutputCPP
bool UnaryOpExpression::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
if (m_op == T_ISSET && m_exp && m_exp->is(Expression::KindOfExpressionList)) {
ExpressionListPtr exps = dynamic_pointer_cast<ExpressionList>(m_exp);
int count = exps->getCount();
if (count > 1) {
bool fix_e1 = (*exps)[0]->preOutputCPP(cg, ar, 0);
bool inExpression = ar->inExpression();
ar->setInExpression(false);
bool fix_en = false;
for (int i = 1; i < count; i++) {
if ((*exps)[i]->preOutputCPP(cg, ar, 0)) {
fix_en = true;
break;
}
}
ar->setInExpression(inExpression);
if (inExpression && fix_en) {
ar->wrapExpressionBegin(cg);
std::string tmp = genCPPTemp(cg, ar);
cg_printf("bool %s = (", tmp.c_str());
(*exps)[0]->outputCPPExistTest(cg, ar, m_op);
cg_printf(");\n");
for (int i = 1; i < count; i++) {
cg_indentBegin("if (%s) {\n", tmp.c_str());
ExpressionPtr e = (*exps)[i];
e->preOutputCPP(cg, ar, 0);
cg_printf("%s = (", tmp.c_str());
e->outputCPPExistTest(cg, ar, m_op);
cg_printf(");\n");
}
for (int i = 1; i < count; i++) {
cg_indentEnd("}\n");
}
m_cppTemp = tmp;
} else if (state & FixOrder) {
preOutputStash(cg, ar, state);
fix_e1 = true;
}
return fix_e1 || fix_en;
}
}
if (m_op == '@') {
if (isUnused()) m_exp->setUnused(true);
bool inExpression = ar->inExpression();
bool doit = state & FixOrder;
if (!doit) {
ar->setInExpression(false);
if (m_exp->preOutputCPP(cg, ar, state)) {
doit = true;
}
ar->setInExpression(inExpression);
}
if (doit && inExpression) {
cg_printf("%s%d.enable();\n", Option::SilencerPrefix, m_silencer);
m_exp->preOutputCPP(cg, ar, 0);
int s = m_silencer;
m_silencer = -1;
this->preOutputStash(cg, ar, state | FixOrder);
m_silencer = s;
cg_printf("%s%d.disable();\n", Option::SilencerPrefix, m_silencer);
}
return doit;
} else if (m_op == T_PRINT && m_exp && !m_exp->hasEffect()) {
ExpressionPtrVec ev;
bool hasVoid = false;
if (BinaryOpExpression::getConcatList(ev, m_exp, hasVoid) > 1 ||
hasVoid ) {
if (!ar->inExpression()) return true;
ar->wrapExpressionBegin(cg);
for (int i = 0, s = ev.size(); i < s; i++) {
ExpressionPtr e = ev[i];
e->preOutputCPP(cg, ar, 0);
cg_printf("print(");
e->outputCPP(cg, ar);
cg_printf(");\n");
}
m_cppTemp = "1";
return true;
}
}
return Expression::preOutputCPP(cg, ar, state);
}