本文整理汇总了C++中AnalysisResultPtr::inExpression方法的典型用法代码示例。如果您正苦于以下问题:C++ AnalysisResultPtr::inExpression方法的具体用法?C++ AnalysisResultPtr::inExpression怎么用?C++ AnalysisResultPtr::inExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnalysisResultPtr
的用法示例。
在下文中一共展示了AnalysisResultPtr::inExpression方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: preOutputCPP
bool FunctionCall::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
if (isUnused() ||
m_className.empty() ||
m_origClassName == "self" ||
m_origClassName == "parent") {
return Expression::preOutputCPP(cg, ar, state);
}
if (!ar->inExpression()) {
return true;
}
Expression::preOutputCPP(cg, ar, state & ~FixOrder);
ar->wrapExpressionBegin(cg);
cg_printf("FrameInjection::SetStaticClassName(info, ");
cg_printString(m_origClassName, ar);
cg_printf(");\n");
m_noStatic = true;
preOutputStash(cg, ar, FixOrder);
m_noStatic = false;
cg_printf("FrameInjection::ResetStaticClassName(info);\n");
if (!(state & FixOrder)) {
cg_printf("id(%s);\n", cppTemp().c_str());
}
return true;
}
示例2: preOutputCPP
bool QOpExpression::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
if (!hasEffect()) {
return Expression::preOutputCPP(cg, ar, state);
}
bool fix_condition = m_condition->preOutputCPP(cg, ar, 0);
if (!ar->inExpression()) {
return fix_condition ||
m_expYes->preOutputCPP(cg, ar, 0) ||
m_expNo->preOutputCPP(cg, ar, 0);
}
ar->setInExpression(false);
bool fix_yes = m_expYes->preOutputCPP(cg, ar, 0);
bool fix_no = m_expYes->preOutputCPP(cg, ar, 0);
ar->setInExpression(true);
if (fix_yes || fix_no) {
ar->wrapExpressionBegin(cg);
std::string tmp = genCPPTemp(cg, ar);
TypePtr typeYes = m_expYes->getActualType();
TypePtr typeNo = m_expNo->getActualType();
TypePtr type =
typeYes && typeNo && Type::SameType(typeYes, typeNo) &&
!typeYes->is(Type::KindOfVariant) &&
m_expYes->isLiteralString() == m_expNo->isLiteralString() ?
typeYes : Type::Variant;
type->outputCPPDecl(cg, ar);
cg_printf(" %s;\n", tmp.c_str());
cg_printf("if (");
m_condition->outputCPP(cg, ar);
cg_indentBegin(") {\n");
m_expYes->preOutputCPP(cg, ar, 0);
cg_printf("%s = (", tmp.c_str());
m_expYes->outputCPP(cg, ar);
cg_indentEnd(");\n");
cg_indentBegin("} else {\n");
m_expNo->preOutputCPP(cg, ar, 0);
cg_printf("%s = (", tmp.c_str());
m_expNo->outputCPP(cg, ar);
cg_printf(");\n");
cg_indentEnd("}\n");
m_cppValue = tmp;
} else if (state & FixOrder) {
preOutputStash(cg, ar, state);
return true;
}
return false;
}
示例3: 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);
}
示例4: preOutputCPP
bool FunctionCall::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
if (m_className.empty() ||
m_origClassName == "self" ||
m_origClassName == "parent") {
return Expression::preOutputCPP(cg, ar, state);
}
if (!ar->inExpression()) {
return true;
}
Expression::preOutputCPP(cg, ar, state | FixOrder);
if (!(state & FixOrder)) {
cg_printf("id(%s);\n", cppTemp().c_str());
}
return true;
}
示例5: outputCPPUnneeded
bool ExpressionList::outputCPPUnneeded(CodeGenerator &cg,
AnalysisResultPtr ar) {
bool inExpression = ar->inExpression();
bool wrapped = false;
if (!inExpression) {
ar->setInExpression(true);
wrapped = preOutputCPP(cg, ar, 0);
}
outputCPPInternal(cg, ar, false, false);
if (!inExpression) {
if (wrapped) cg.printf(";\n");
ar->wrapExpressionEnd(cg);
ar->setInExpression(inExpression);
}
return true;
}
示例6: preOutputCPP
bool NewObjectExpression::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
bool tempRcvr = true;
if (m_name.empty() || m_redeclared || !m_validClass || m_dynamic) {
tempRcvr = false;
}
bool paramEffect = false;
if (m_params && m_params->getCount() > 0) {
for (int i = m_params->getCount(); i--; ) {
if (!(*m_params)[i]->isScalar()) {
paramEffect = true;
break;
}
}
}
if (!paramEffect) {
tempRcvr = false;
}
if (tempRcvr && ar->inExpression()) {
ar->wrapExpressionBegin(cg);
m_receiverTemp = genCPPTemp(cg, ar);
bool outsideClass = !ar->checkClassPresent(m_origName);
cg.printf("%s%s *%s = ", Option::ClassPrefix, m_name.c_str(),
m_receiverTemp.c_str());
ClassScopePtr cls = ar->resolveClass(m_name);
ASSERT(cls);
if (outsideClass) {
cls->outputVolatileCheckBegin(cg, ar, m_origName);
}
cg.printf("NEWOBJ(%s%s)()", Option::ClassPrefix, m_name.c_str());
if (outsideClass) {
cls->outputVolatileCheckEnd(cg);
}
cg.printf(";\n");
}
bool tempParams = FunctionCall::preOutputCPP(cg, ar, state);
return tempRcvr || tempParams;
}
示例7: preOutputCPP
bool ExpressionList::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
if (m_kind == ListKindParam && !m_arrayElements) {
return Expression::preOutputCPP(cg, ar, state|StashKidVars);
}
bool inExpression = ar->inExpression();
ar->setInExpression(false);
bool ret = false;
if (m_arrayElements) {
ret = Expression::preOutputCPP(cg, ar, state);
} else {
for (unsigned int i = 0; i < m_exps.size(); i++) {
if (m_exps[i]->preOutputCPP(cg, ar, 0)) {
ret = true;
break;
}
}
}
if (!inExpression) return ret;
ar->setInExpression(true);
if (!ret) return false;
ar->wrapExpressionBegin(cg);
if (m_arrayElements) {
setCPPTemp(genCPPTemp(cg, ar));
outputCPPInternal(cg, ar, true, true);
} else {
for (unsigned int i = 0, n = m_exps.size(); i < n; i++) {
ExpressionPtr e = m_exps[i];
e->preOutputCPP(cg, ar, state);
if (i < n - 1) {
if (e->outputCPPUnneeded(cg, ar)) {
cg.printf(";\n");
}
e->setCPPTemp("/**/");
}
}
}
return true;
}
示例8: preOutputCPP
bool ListAssignment::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
ASSERT(m_array);
if (!ar->inExpression()) return true;
if (m_variables) {
preOutputVariables(cg, ar, m_variables->hasEffect() ||
m_array->hasEffect() ? FixOrder : 0);
}
m_array->preOutputCPP(cg, ar, 0);
bool isArray = false, notArray = false;
if (TypePtr type = m_array->getActualType()) {
isArray = type->is(Type::KindOfArray);
notArray = type->isPrimitive() ||
type->is(Type::KindOfString) ||
type->is(Type::KindOfObject);
}
m_cppTemp = genCPPTemp(cg, ar);
ar->wrapExpressionBegin(cg);
if (outputLineMap(cg, ar)) cg_printf("0);\n");
cg_printf("CVarRef %s((", m_cppTemp.c_str());
m_array->outputCPP(cg, ar);
cg_printf("));\n");
std::string tmp;
if (notArray) {
tmp = "null";
} else {
tmp = genCPPTemp(cg, ar);
cg_printf("Variant %s((ref(%s)));\n", tmp.c_str(), m_cppTemp.c_str());
if (!isArray) {
cg_printf("if (!f_is_array(%s)) %s.unset();\n",tmp.c_str(),
tmp.c_str());
}
}
outputCPPAssignment(cg, ar, tmp);
return true;
}
示例9: preOutputCPP
bool FunctionCall::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
if (isUnused() ||
m_className.empty() ||
m_origClassName == "self" ||
m_origClassName == "parent") {
return Expression::preOutputCPP(cg, ar, state);
}
if (!ar->inExpression()) {
return true;
}
Expression::preOutputCPP(cg, ar, state & ~FixOrder);
ar->wrapExpressionBegin(cg);
if (m_classScope) {
string className = m_classScope->getId(cg);
cg_printf("FrameInjection::SetStaticClassName(info, "
"%s%s::s_class_name);\n",
Option::ClassPrefix, className.c_str());
} else {
m_clsNameTemp = cg.createNewId(shared_from_this());
cg_printf("CStrRef clsName%d(", m_clsNameTemp);
cg_printString(m_origClassName, ar, shared_from_this());
cg_printf(");\n");
cg_printf("FrameInjection::SetStaticClassName(info, clsName%d);\n",
m_clsNameTemp);
}
m_noStatic = true;
preOutputStash(cg, ar, FixOrder);
m_noStatic = false;
cg_printf("FrameInjection::ResetStaticClassName(info);\n");
if (!(state & FixOrder)) {
cg_printf("id(%s);\n", cppTemp().c_str());
}
return true;
}
示例10: 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);
}
示例11: preOutputCPP
bool NewObjectExpression::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
string &cname = (m_origName == "self" || m_origName == "parent") ?
m_name : m_origName;
if (m_name.empty() || m_redeclared || !m_validClass || m_dynamic) {
// Short circuit out if inExpression() returns false
if (!ar->inExpression()) return true;
if (m_nameExp) m_nameExp->preOutputCPP(cg, ar, state);
ar->wrapExpressionBegin(cg);
m_ciTemp = cg.createNewId(ar);
m_objectTemp = cg.createNewId(ar);
cg_printf("Object obj%d(", m_objectTemp);
if (m_redeclared) {
bool outsideClass = !ar->checkClassPresent(m_origName);
ClassScopePtr cls = ar->resolveClass(m_name);
ASSERT(cls);
if (outsideClass) {
cls->outputVolatileCheckBegin(cg, ar, cname);
}
cg_printf("g->%s%s->createOnly()", Option::ClassStaticsObjectPrefix,
m_name.c_str());
if (outsideClass) {
cls->outputVolatileCheckEnd(cg);
}
} else {
cg_printf("create_object_only(");
if (!cname.empty()) {
cg_printf("\"%s\"", cname.c_str());
} else if (m_nameExp->is(Expression::KindOfSimpleVariable)) {
m_nameExp->outputCPP(cg, ar);
} else {
cg_printf("(");
m_nameExp->outputCPP(cg, ar);
cg_printf(")");
}
cg_printf(")");
}
cg_printf(");\n");
cg_printf("MethodCallPackage mcp%d;\n", m_ciTemp,
m_objectTemp);
cg_printf("mcp%d.construct(obj%d);\n", m_ciTemp, m_objectTemp);
cg_printf("const CallInfo *cit%d = mcp%d.ci;\n", m_ciTemp, m_ciTemp);
if (m_params && m_params->getCount() > 0) {
ar->pushCallInfo(m_ciTemp);
m_params->preOutputCPP(cg, ar, state);
ar->popCallInfo();
}
cg_printf("(cit%d->getMeth())(mcp%d, ", m_ciTemp, m_ciTemp);
if (m_params && m_params->getOutputCount()) {
ar->pushCallInfo(m_ciTemp);
FunctionScope::outputCPPArguments(m_params, cg, ar, -1, false);
ar->popCallInfo();
} else {
cg_printf("Array()");
}
cg_printf(");\n");
if (state & FixOrder) {
ar->pushCallInfo(m_ciTemp);
preOutputStash(cg, ar, state);
ar->popCallInfo();
}
if (hasCPPTemp() && !(state & FixOrder)) {
cg_printf("id(%s);\n", cppTemp().c_str());
}
return true;
} else {
bool tempRcvr = true;
bool paramEffect = false;
if (m_params && m_params->getCount() > 0) {
for (int i = m_params->getCount(); i--; ) {
if (!(*m_params)[i]->isScalar()) {
paramEffect = true;
break;
}
}
}
if (!paramEffect) {
tempRcvr = false;
}
if (tempRcvr && ar->inExpression()) {
bool outsideClass = !ar->checkClassPresent(m_origName);
ClassScopePtr cls = ar->resolveClass(m_name);
ASSERT(cls);
ar->wrapExpressionBegin(cg);
m_receiverTemp = genCPPTemp(cg, ar);
cg_printf("%s%s %s = ", Option::SmartPtrPrefix, cls->getId(cg).c_str(),
m_receiverTemp.c_str());
if (outsideClass) {
cls->outputVolatileCheckBegin(cg, ar, cname);
}
cg_printf("NEWOBJ(%s%s)()", Option::ClassPrefix, cls->getId(cg).c_str());
if (outsideClass) {
cls->outputVolatileCheckEnd(cg);
//.........这里部分代码省略.........
示例12: preOutputCPP
bool ObjectMethodExpression::preOutputCPP(CodeGenerator &cg,
AnalysisResultPtr ar, int state) {
if (!m_name.empty() && m_valid && m_object->getType()->isSpecificObject()) {
return FunctionCall::preOutputCPP(cg, ar, state);
}
// Short circuit out if inExpression() returns false
if (!ar->inExpression()) return true;
m_ciTemp = cg.createNewId(shared_from_this());
ar->wrapExpressionBegin(cg);
bool isThis = m_object->isThis();
if (!isThis) {
m_object->preOutputCPP(cg, ar, state);
}
if (m_name.empty()) {
m_nameExp->preOutputCPP(cg, ar, state);
}
const MethodSlot *ms = NULL;
if (!m_name.empty()) {
ConstructPtr self = shared_from_this();
ms = ar->getOrAddMethodSlot(m_name, self);
}
cg_printf("MethodCallPackage mcp%d;\n", m_ciTemp);
if (ms) {
cg_printf("mcp%d.methodCallWithIndex((", m_ciTemp);
} else {
cg_printf("mcp%d.methodCall((", m_ciTemp);
}
if (isThis) {
cg_printf("GET_THIS()");
} else {
outputCPPObject(cg, ar);
}
cg_printf("), ");
if (!m_name.empty()) {
uint64 hash = hash_string_i(m_name.c_str());
cg_printString(m_origName, ar, shared_from_this());
if (ms) {
cg_printf(", %s", ms->runObjParam().c_str());
}
cg_printf(", 0x%016llXLL);\n", hash);
} else {
m_nameExp->outputCPP(cg, ar);
cg_printf(", -1);\n");
}
cg_printf("const CallInfo *cit%d __attribute__((__unused__)) ="
" mcp%d.ci;\n", m_ciTemp, m_ciTemp);
if (m_params && m_params->getCount() > 0) {
ar->pushCallInfo(m_ciTemp);
m_params->preOutputCPP(cg, ar, state);
ar->popCallInfo();
}
if (state & FixOrder) {
ar->pushCallInfo(m_ciTemp);
preOutputStash(cg, ar, state);
ar->popCallInfo();
}
if (hasCPPTemp() && !(state & FixOrder)) {
cg_printf("id(%s);\n", cppTemp().c_str());
}
return true;
}
示例13: preOutputCPP
bool DynamicFunctionCall::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
bool nonStatic = !m_class && m_className.empty();
if (!nonStatic && !m_class && !m_validClass && !m_redeclared)
return FunctionCall::preOutputCPP(cg, ar, state);
// Short circuit out if inExpression() returns false
if (!ar->inExpression()) return true;
if (m_class) {
m_class->preOutputCPP(cg, ar, state);
}
m_nameExp->preOutputCPP(cg, ar, state);
ar->wrapExpressionBegin(cg);
m_ciTemp = cg.createNewId(shared_from_this());
bool lsb = false;
ClassScopePtr cls;
if (m_validClass) {
cls = ar->findClass(m_className);
}
if (!m_classScope && !m_className.empty() && m_cppTemp.empty() &&
m_origClassName != "self" && m_origClassName != "parent" &&
m_origClassName != "static") {
// Create a temporary to hold the class name, in case it is not a
// StaticString.
m_clsNameTemp = cg.createNewId(shared_from_this());
cg_printf("CStrRef clsName%d(", m_clsNameTemp);
cg_printString(m_origClassName, ar, shared_from_this());
cg_printf(");\n");
}
if (nonStatic) {
cg_printf("const CallInfo *cit%d;\n", m_ciTemp);
cg_printf("void *vt%d;\n", m_ciTemp);
cg_printf("get_call_info_or_fail(cit%d, vt%d, ", m_ciTemp, m_ciTemp);
} else {
cg_printf("MethodCallPackage mcp%d;\n", m_ciTemp);
if (m_class) {
if (m_class->is(KindOfScalarExpression)) {
ASSERT(strcasecmp(dynamic_pointer_cast<ScalarExpression>(m_class)->
getString().c_str(), "static") == 0);
cg_printf("mcp%d.staticMethodCall(", m_ciTemp);
cg_printf("\"static\"");
lsb = true;
} else {
cg_printf("mcp%d.dynamicNamedCall(", m_ciTemp);
m_class->outputCPP(cg, ar);
}
cg_printf(", ");
} else if (m_validClass) {
cg_printf("mcp%d.staticMethodCall(\"%s\", ", m_ciTemp,
cls->getId(cg).c_str());
} else {
cg_printf("mcp%d.staticMethodCall(\"%s\", ", m_ciTemp,
m_className.c_str());
}
}
if (m_nameExp->is(Expression::KindOfSimpleVariable)) {
m_nameExp->outputCPP(cg, ar);
} else {
cg_printf("(");
m_nameExp->outputCPP(cg, ar);
cg_printf(")");
}
if (!nonStatic) {
cg_printf(");\n");
if (lsb) cg_printf("mcp%d.lateStaticBind(info);\n");
cg_printf("const CallInfo *&cit%d = mcp%d.ci;\n", m_ciTemp, m_ciTemp);
if (m_validClass) {
cg_printf("%s%s::%sget_call_info(mcp%d",
Option::ClassPrefix, cls->getId(cg).c_str(),
Option::ObjectStaticPrefix, m_ciTemp, m_className.c_str());
} else if (m_redeclared) {
cg_printf("g->%s%s->%sget_call_info(mcp%d",
Option::ClassStaticsObjectPrefix, m_className.c_str(),
Option::ObjectStaticPrefix, m_ciTemp, m_className.c_str());
}
}
if (nonStatic || !m_class) {
cg_printf(");\n");
}
if (m_params && m_params->getCount() > 0) {
ar->pushCallInfo(m_ciTemp);
m_params->preOutputCPP(cg, ar, state);
ar->popCallInfo();
}
ar->pushCallInfo(m_ciTemp);
preOutputStash(cg, ar, state);
ar->popCallInfo();
if (!(state & FixOrder)) {
cg_printf("id(%s);\n", cppTemp().c_str());
}
return true;
}
示例14: preOutputCPP
bool ExpressionList::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
int state) {
if (m_kind == ListKindParam && !m_arrayElements) {
return Expression::preOutputCPP(cg, ar, state|StashKidVars);
}
unsigned n = m_exps.size();
bool inExpression = ar->inExpression();
if (!inExpression && (state & FixOrder)) {
return true;
}
ar->setInExpression(false);
bool ret = false;
if (m_arrayElements) {
/*
* would like to do:
* ret = Expression::preOutputCPP(cg, ar, state);
* but icc has problems with the generated code.
*/
ret = hasEffect();
} else if (n > 1 && m_kind == ListKindLeft) {
ret = true;
} else {
for (unsigned int i = 0; i < n; i++) {
if (m_exps[i]->preOutputCPP(cg, ar, 0)) {
ret = true;
break;
}
}
}
if (!inExpression) return ret;
ar->setInExpression(true);
if (!ret) {
if (state & FixOrder) {
preOutputStash(cg, ar, state);
return true;
}
return false;
}
ar->wrapExpressionBegin(cg);
if (m_arrayElements) {
setCPPTemp(genCPPTemp(cg, ar));
outputCPPInternal(cg, ar, true, true);
} else {
unsigned ix = m_kind == ListKindLeft ? 0 : n - 1;
for (unsigned int i = 0; i < n; i++) {
ExpressionPtr e = m_exps[i];
e->preOutputCPP(cg, ar, 0);
if (i != ix) {
if (e->outputCPPUnneeded(cg, ar)) {
cg_printf(";\n");
}
e->setCPPTemp("/**/");
} else if (!i && n > 1) {
e->Expression::preOutputStash(cg, ar, state | FixOrder);
if (!(state & FixOrder)) {
cg_printf("id(%s);\n", e->cppTemp().c_str());
}
setCPPTemp(e->cppTemp());
}
}
}
return true;
}
示例15: 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, hasLitStr = false;
int numConcat = 0;
bool ok = false;
if (m_op == '.') {
numConcat = getConcatList(ev, self, hasVoid, hasLitStr);
ok = hasVoid ||
(hasLitStr && !Option::PrecomputeLiteralStrings) ||
(numConcat > MAX_CONCAT_ARGS &&
(!Option::GenConcat ||
cg.getOutput() == CodeGenerator::SystemCPP));
} else if (effect2 && m_op == T_CONCAT_EQUAL) {
prefix = stringBufferPrefix(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, hasLitStr);
}
if (ok) {
if (!ar->inExpression()) return true;
ar->wrapExpressionBegin(cg);
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 (!ar->inExpression()) {
return fix_e1 || m_exp2->preOutputCPP(cg, ar, 0);
}
ar->setInExpression(false);
bool fix_e2 = m_exp2->preOutputCPP(cg, ar, 0);
ar->setInExpression(true);
if (fix_e2) {
ar->wrapExpressionBegin(cg);
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());
//.........这里部分代码省略.........