本文整理汇总了C++中ParameterPtr::isOptional方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterPtr::isOptional方法的具体用法?C++ ParameterPtr::isOptional怎么用?C++ ParameterPtr::isOptional使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterPtr
的用法示例。
在下文中一共展示了ParameterPtr::isOptional方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void FunctionStatement::init(void *parser, bool ref,
const vector<ParameterPtr> ¶ms,
StatementListStatementPtr body,
bool has_call_to_get_args) {
m_ref = ref;
m_params = params;
m_body = body;
m_hasCallToGetArgs = has_call_to_get_args;
const CallInfo* cit1;
void* vt1;
if (get_call_info_no_eval(cit1, vt1, m_name)) {
m_invalid =
get_call_info_builtin(cit1, vt1, m_name->data(), m_name->hash()) ? -1 : 1;
}
bool seenOptional = false;
set<string> names;
m_callInfo.m_argCount = m_closureCallInfo.m_argCount = m_params.size();
for (unsigned int i = 0; i < m_params.size(); i++) {
ParameterPtr param = m_params[i];
std::string name = param->name();
if (names.find(name) != names.end()) {
raise_notice("%s:%d %s() has 2 parameters with the same name: $%s",
m_loc.file, m_loc.line0, m_name.c_str(), name.c_str());
} else {
names.insert(name);
}
if (!seenOptional) {
if (param->isOptional()) {
seenOptional = true;
}
} else if (!param->isOptional()) {
/*
raise_notice("%s:%d %s() has required parameter after optional one: $%s",
m_loc.file, m_loc.line0, m_name.c_str(), name.c_str());
*/
param->addNullDefault(parser);
}
if (param->isRef()) {
m_callInfo.m_refFlags |= 1 << i;
m_closureCallInfo.m_refFlags |= 1 << i;
}
if (param->getIdx() == -1) {
param->setIdx(declareVariable(name));
}
}
}