本文整理汇总了C++中MethodStatementPtr::hasRefParam方法的典型用法代码示例。如果您正苦于以下问题:C++ MethodStatementPtr::hasRefParam方法的具体用法?C++ MethodStatementPtr::hasRefParam怎么用?C++ MethodStatementPtr::hasRefParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MethodStatementPtr
的用法示例。
在下文中一共展示了MethodStatementPtr::hasRefParam方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outputCPPParamsCall
void FunctionScope::outputCPPParamsCall(CodeGenerator &cg,
AnalysisResultPtr ar,
bool aggregateParams) {
if (isVariableArgument()) {
cg_printf("num_args, ");
}
bool userFunc = isUserFunction();
MethodStatementPtr stmt;
ExpressionListPtr params;
if (userFunc) {
stmt = dynamic_pointer_cast<MethodStatement>(m_stmt);
params = stmt->getParams();
}
bool arrayCreated = false;
if (Option::GenArrayCreate &&
cg.getOutput() != CodeGenerator::SystemCPP &&
aggregateParams && m_maxParam > 0) {
if (stmt && !stmt->hasRefParam()) {
cg_printf("Array(");
stmt->outputParamArrayInit(cg);
cg_printf(")");
arrayCreated = true;
} else if (!userFunc && !hasRefParam(m_maxParam)) {
cg_printf("Array(");
for (int i = 0; i < m_maxParam; i++) {
if (isRefParam(i)) {
cg_printf("%d, ref(a%d)", i, i);
} else {
cg_printf("%d, a%d", i, i);
}
if (i < m_maxParam - 1) {
cg_printf(", ");
} else {
cg_printf(")");
}
}
cg_printf(")");
arrayCreated = true;
}
}
if (arrayCreated && isVariableArgument()) {
cg_printf(",");
cg_printf("args");
return;
}
if (aggregateParams) {
cg_printf("Array(");
if (m_maxParam) {
// param arrays are always vectors
cg_printf("ArrayInit(%d, true).", m_maxParam);
}
}
for (int i = 0; i < m_maxParam; i++) {
if (i > 0) cg_printf(aggregateParams ? "." : ", ");
bool isRef;
if (userFunc) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*params)[i]);
isRef = param->isRef();
if (aggregateParams) {
cg_printf("set%s(v_%s", isRef ? "Ref" : "",
param->getName().c_str());
} else {
cg_printf("%sv_%s%s",
isRef ? "ref(" : "", param->getName().c_str(),
isRef ? ")" : "");
}
} else {
isRef = isRefParam(i);
if (aggregateParams) {
cg_printf("set%s(a%d", isRef ? "Ref" : "", i);
} else {
cg_printf("%sa%d%s",
isRef ? "ref(" : "", i, isRef ? ")" : "");
}
}
if (aggregateParams) cg_printf(")");
}
if (aggregateParams) {
if (m_maxParam) cg_printf(".create()");
cg_printf(")");
}
if (isVariableArgument()) {
if (aggregateParams || m_maxParam > 0) cg_printf(",");
cg_printf("args");
}
}