本文整理汇总了C++中AnalysisResultPtr::outputCPPScalarArrayId方法的典型用法代码示例。如果您正苦于以下问题:C++ AnalysisResultPtr::outputCPPScalarArrayId方法的具体用法?C++ AnalysisResultPtr::outputCPPScalarArrayId怎么用?C++ AnalysisResultPtr::outputCPPScalarArrayId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnalysisResultPtr
的用法示例。
在下文中一共展示了AnalysisResultPtr::outputCPPScalarArrayId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outputCPPArguments
void FunctionScope::outputCPPArguments(ExpressionListPtr params,
CodeGenerator &cg,
AnalysisResultPtr ar, int extraArg,
bool variableArgument,
int extraArgArrayId /* = -1 */,
int extraArgArrayHash /* = -1 */,
int extraArgArrayIndex /* = -1 */) {
int paramCount = params ? params->getOutputCount() : 0;
ASSERT(extraArg <= paramCount);
int iMax = paramCount - extraArg;
bool extra = false;
if (variableArgument) {
if (paramCount == 0) {
cg_printf("0");
} else {
cg_printf("%d, ", paramCount);
}
}
int firstExtra = 0;
for (int i = 0; i < paramCount; i++) {
ExpressionPtr param = (*params)[i];
cg.setItemIndex(i);
if (i > 0) cg_printf(extra ? "." : ", ");
if (!extra && (i == iMax || extraArg < 0)) {
if (extraArgArrayId != -1) {
assert(extraArgArrayHash != -1 && extraArgArrayIndex != -1);
ar->outputCPPScalarArrayId(cg, extraArgArrayId, extraArgArrayHash,
extraArgArrayIndex);
break;
}
extra = true;
// Parameter arrays are always vectors.
if (Option::GenArrayCreate &&
cg.getOutput() != CodeGenerator::SystemCPP) {
if (!params->hasNonArrayCreateValue(false, i)) {
ar->m_arrayIntegerKeySizes.insert(paramCount - i);
cg_printf("Array(");
params->outputCPPUniqLitKeyArrayInit(cg, ar, paramCount - i,
false, i);
cg_printf(")");
return;
}
}
firstExtra = i;
cg_printf("Array(ArrayInit(%d, true).", paramCount - i);
}
if (extra) {
bool needRef = param->hasContext(Expression::RefValue) &&
!param->hasContext(Expression::NoRefWrapper) &&
param->isRefable();
cg_printf("set%s(", needRef ? "Ref" : "");
if (needRef) {
// The parameter itself shouldn't be wrapped with ref() any more.
param->setContext(Expression::NoRefWrapper);
}
param->outputCPP(cg, ar);
cg_printf(")");
} else {
param->outputCPP(cg, ar);
}
}
if (extra) {
cg_printf(".create())");
}
}
示例2: outputCPPImpl
void UnaryOpExpression::outputCPPImpl(CodeGenerator &cg,
AnalysisResultPtr ar) {
if ((m_op == T_INC || m_op == T_DEC) && outputCPPImplOpEqual(cg, ar)) {
return;
}
if (m_op == T_ARRAY &&
(getContext() & (RefValue|LValue)) == 0 &&
!ar->getInsideScalarArray()) {
int id = -1;
int hash = -1;
int index = -1;
string text;
if (m_exp) {
ExpressionListPtr pairs = dynamic_pointer_cast<ExpressionList>(m_exp);
Variant v;
if (pairs && pairs->isScalarArrayPairs() && pairs->getScalarValue(v)) {
id = ar->registerScalarArray(getFileScope(), m_exp, hash, index, text);
}
} else {
id = ar->registerScalarArray(getFileScope(), m_exp,
hash, index, text); // empty array
}
if (id != -1) {
if (Option::UseNamedScalarArray &&
cg.getContext() == CodeGenerator::CppParameterDefaultValueDecl) {
getFileScope()->addUsedDefaultValueScalarArray(text);
}
ar->outputCPPScalarArrayId(cg, id, hash, index);
return;
}
}
if ((m_op == T_ISSET || m_op == T_EMPTY || m_op == T_UNSET) && m_exp) {
if (m_exp->is(Expression::KindOfExpressionList)) {
ExpressionListPtr exps = dynamic_pointer_cast<ExpressionList>(m_exp);
if (exps->getListKind() == ExpressionList::ListKindParam) {
int count = exps->getCount();
if (count > 1) {
cg_printf("(");
}
for (int i = 0; i < count; i++) {
if (m_op == T_UNSET) {
if (i > 0) cg_printf(", ");
(*exps)[i]->outputCPPUnset(cg, ar);
} else {
if (i > 0) cg_printf(" && ");
(*exps)[i]->outputCPPExistTest(cg, ar, m_op);
}
}
if (exps->getCount() > 1) {
cg_printf(")");
}
return;
}
}
if (m_op == T_UNSET) {
m_exp->outputCPPUnset(cg, ar);
} else {
m_exp->outputCPPExistTest(cg, ar, m_op);
}
return;
}
if (m_front) {
switch (m_op) {
case T_CLONE: cg_printf("f_clone("); break;
case T_INC: cg_printf("++"); break;
case T_DEC: cg_printf("--"); break;
case '+': cg_printf("+"); break;
case '-': cg_printf("negate("); break;
case '!': cg_printf("!("); break;
case '~': cg_printf("~"); break;
case '(': cg_printf("("); break;
case T_INT_CAST: cg_printf("("); break;
case T_DOUBLE_CAST: cg_printf("("); break;
case T_STRING_CAST: cg_printf("("); break;
case T_ARRAY_CAST: cg_printf("("); break;
case T_OBJECT_CAST: cg_printf("("); break;
case T_BOOL_CAST: cg_printf("("); break;
case T_UNSET_CAST:
if (m_exp->hasCPPTemp()) {
cg_printf("(id(");
} else {
cg_printf("(");
}
break;
case T_EXIT: cg_printf("f_exit("); break;
case T_ARRAY:
cg_printf("Array(");
break;
case T_PRINT: cg_printf("print("); break;
case T_EVAL:
if (Option::EnableEval > Option::NoEval) {
bool instance;
if (getClassScope()) {
FunctionScopePtr fs = getFunctionScope();
instance = fs && !fs->isStatic();
} else {
instance = false;
}
//.........这里部分代码省略.........
示例3: outputCPPImpl
void UnaryOpExpression::outputCPPImpl(CodeGenerator &cg,
AnalysisResultPtr ar) {
if ((m_op == T_INC || m_op == T_DEC) && outputCPPImplOpEqual(cg, ar)) {
return;
}
if (m_op == T_ARRAY &&
(getContext() & (RefValue|LValue)) == 0 &&
!cg.getInsideScalarArray()) {
int id = -1;
int hash = -1;
int index = -1;
string text;
if (m_exp) {
ExpressionListPtr pairs = dynamic_pointer_cast<ExpressionList>(m_exp);
Variant v;
if (pairs && pairs->isScalarArrayPairs() && pairs->getScalarValue(v)) {
id = ar->registerScalarArray(cg.getInsideScalarArray(), getFileScope(),
m_exp, hash, index, text);
}
} else {
id = ar->registerScalarArray(cg.getInsideScalarArray(), getFileScope(),
m_exp, hash, index, text); // empty array
}
if (id != -1) {
bool scalarVariant =
Option::UseScalarVariant && cg.hasScalarVariant();
if (scalarVariant) {
ar->addNamedScalarVarArray(text);
getFileScope()->addUsedScalarVarArray(text);
}
if (Option::UseNamedScalarArray && cg.isFileOrClassHeader()) {
if (getClassScope()) {
getClassScope()->addUsedDefaultValueScalarArray(text);
if (scalarVariant) {
getClassScope()->addUsedDefaultValueScalarVarArray(text);
}
} else {
getFileScope()->addUsedDefaultValueScalarArray(text);
if (scalarVariant) {
getFileScope()->addUsedDefaultValueScalarVarArray(text);
}
}
}
ar->outputCPPScalarArrayId(cg, id, hash, index, scalarVariant);
return;
}
}
if ((m_op == T_ISSET || m_op == T_EMPTY || m_op == T_UNSET) && m_exp) {
if (m_exp->is(Expression::KindOfExpressionList)) {
ExpressionListPtr exps = dynamic_pointer_cast<ExpressionList>(m_exp);
if (exps->getListKind() == ExpressionList::ListKindParam) {
int count = exps->getCount();
if (count > 1) {
cg_printf("(");
}
for (int i = 0; i < count; i++) {
if (m_op == T_UNSET) {
if (i > 0) cg_printf(", ");
(*exps)[i]->outputCPPUnset(cg, ar);
} else {
if (i > 0) cg_printf(" && ");
(*exps)[i]->outputCPPExistTest(cg, ar, m_op);
}
}
if (exps->getCount() > 1) {
cg_printf(")");
}
return;
}
}
if (m_op == T_UNSET) {
m_exp->outputCPPUnset(cg, ar);
} else {
m_exp->outputCPPExistTest(cg, ar, m_op);
}
return;
}
ASSERT(m_op != T_CLASS && m_op != T_FUNCTION);
const char *cstr = 0;
if (m_front) {
switch (m_op) {
case T_CLONE: cg_printf("f_clone("); break;
case T_INC: cg_printf("++"); break;
case T_DEC: cg_printf("--"); break;
case '+': cg_printf("+"); break;
case '-': cg_printf("negate("); break;
case '!': cg_printf("!("); break;
case '~': cg_printf("~"); break;
case T_INT_CAST: cg_printf("("); break;
case T_DOUBLE_CAST: cg_printf("("); break;
case T_STRING_CAST: cstr = "String"; goto null_cast;
case T_ARRAY_CAST: cstr = "Array"; goto null_cast;
case T_OBJECT_CAST: cstr = "Object"; goto null_cast;
null_cast: {
TypePtr at = m_exp->getActualType();
TypePtr et = m_exp->getType();
TypePtr it = m_exp->getCPPType();
//.........这里部分代码省略.........