本文整理汇总了C++中ArrayPairExpressionPtr::isRef方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayPairExpressionPtr::isRef方法的具体用法?C++ ArrayPairExpressionPtr::isRef怎么用?C++ ArrayPairExpressionPtr::isRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayPairExpressionPtr
的用法示例。
在下文中一共展示了ArrayPairExpressionPtr::isRef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outputCPPInternal
bool ExpressionList::outputCPPInternal(CodeGenerator &cg,
AnalysisResultPtr ar,
bool needed, bool pre) {
bool needsComma = false;
bool anyOutput = false;
if (m_arrayElements) {
bool isVector = true;
for (unsigned int i = 0; i < m_exps.size(); i++) {
ArrayPairExpressionPtr ap =
dynamic_pointer_cast<ArrayPairExpression>(m_exps[i]);
if (ap->getName()) {
isVector = false;
break;
}
}
if (outputCPPArrayCreate(cg, ar, isVector, pre)) return true;
cg_printf("ArrayInit");
if (pre) {
cg_printf(" %s", m_cppTemp.c_str());
}
cg_printf("(%d)", (int)m_exps.size());
if (pre) cg_printf(";\n");
needsComma = true;
anyOutput = true;
}
bool trailingComma = false;
unsigned i = 0, s = m_exps.size();
unsigned ix = m_kind == ListKindLeft ? 0 : s - 1;
bool uniqueStringKeys =
m_arrayElements && (checkLitstrKeys() == s); // TODO integer keys as well
for ( ; i < s; i++) {
if (ExpressionPtr exp = m_exps[i]) {
if (pre) {
exp->preOutputCPP(cg, ar, 0);
cg_printf("%s", m_cppTemp.c_str());
}
if (needsComma) {
cg_printf(m_arrayElements ? "." : ", ");
trailingComma = true;
}
if (m_arrayElements) {
ArrayPairExpressionPtr ap =
dynamic_pointer_cast<ArrayPairExpression>(exp);
if (ap->isRef()) {
cg_printf("setRef(");
// The value itself shouldn't be wrapped with ref() any more.
ap->getValue()->setContext(NoRefWrapper);
} else {
cg_printf(uniqueStringKeys ? "add(" : "set(");
}
exp->outputCPP(cg, ar);
cg_printf(")");
if (pre) {
cg_printf(";\n");
}
needsComma = true;
} else if (m_kind != ListKindParam && (i != ix || !needed)) {
needsComma = exp->outputCPPUnneeded(cg, ar);
} else {
bool wrap =
exp->hasCPPTemp() &&
hasContext(LValue) && !hasAnyContext(RefValue|InvokeArgument) &&
!(exp->hasContext(LValue) &&
!exp->hasAnyContext(RefValue|InvokeArgument));
if (wrap) cg_printf("const_cast<Variant&>(");
bool noRef = !exp->hasCPPTemp() &&
hasContext(RefValue) &&
!exp->hasAllContext(LValue|ReturnContext) &&
!exp->hasContext(RefValue) &&
!exp->isTemporary() &&
Type::IsMappedToVariant(exp->getActualType());
if (noRef) cg_printf("wrap_variant(");
exp->outputCPP(cg, ar);
if (noRef) cg_printf(")");
if (wrap) cg_printf(")");
needsComma = true;
}
if (needsComma) {
trailingComma = false;
anyOutput = true;
}
}
}
if (trailingComma) {
cg_printf("id(0)");
}
if (m_arrayElements && !pre) {
cg_printf(".create()");
anyOutput = true;
}
return anyOutput;
}
示例2: outputCPPInternal
bool ExpressionList::outputCPPInternal(CodeGenerator &cg,
AnalysisResultPtr ar,
bool needed, bool pre) {
bool needsComma = false;
bool anyOutput = false;
if (m_arrayElements) {
bool isVector = true;
for (unsigned int i = 0; i < m_exps.size(); i++) {
ArrayPairExpressionPtr ap =
dynamic_pointer_cast<ArrayPairExpression>(m_exps[i]);
if (ap->getName()) {
isVector = false;
break;
}
}
if (outputCPPArrayCreate(cg, ar, isVector, pre)) return true;
cg_printf("ArrayInit");
if (pre) {
cg_printf(" %s", m_cppTemp.c_str());
}
cg_printf("(%d, %s)", m_exps.size(), isVector ? "true" : "false");
if (pre) cg_printf(";\n");
needsComma = true;
anyOutput = true;
}
bool trailingComma = false;
unsigned i = 0, s = m_exps.size();
unsigned ix = m_kind == ListKindLeft ? 0 : s - 1;
for ( ; i < s; i++) {
if (ExpressionPtr exp = m_exps[i]) {
if (pre) {
exp->preOutputCPP(cg, ar, 0);
cg_printf("%s", m_cppTemp.c_str());
}
if (needsComma) {
cg_printf(m_arrayElements ? "." : ", ");
trailingComma = true;
}
if (m_arrayElements) {
ArrayPairExpressionPtr ap =
dynamic_pointer_cast<ArrayPairExpression>(exp);
if (ap->isRef()) {
cg_printf("setRef(");
// The value itself shouldn't be wrapped with ref() any more.
ap->getValue()->setContext(NoRefWrapper);
} else {
cg_printf("set(");
}
exp->outputCPP(cg, ar);
cg_printf(")");
if (pre) {
cg_printf(";\n");
}
needsComma = true;
} else if (m_kind != ListKindParam && (i != ix || !needed)) {
needsComma = exp->outputCPPUnneeded(cg, ar);
} else {
exp->outputCPP(cg, ar);
needsComma = true;
}
if (needsComma) {
trailingComma = false;
anyOutput = true;
}
}
}
if (trailingComma) {
cg_printf("id(0)");
}
if (m_arrayElements && !pre) {
cg_printf(".create()");
anyOutput = true;
}
return anyOutput;
}