本文整理汇总了C++中ParameterExpressionPtr::defaultToNull方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterExpressionPtr::defaultToNull方法的具体用法?C++ ParameterExpressionPtr::defaultToNull怎么用?C++ ParameterExpressionPtr::defaultToNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterExpressionPtr
的用法示例。
在下文中一共展示了ParameterExpressionPtr::defaultToNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onParseImpl
FunctionScopePtr MethodStatement::onParseImpl(AnalysisResultPtr ar) {
int minParam, maxParam;
ConstructPtr self = shared_from_this();
minParam = maxParam = 0;
bool hasRef = false;
if (m_params) {
set<string> names;
int i = 0;
maxParam = m_params->getCount();
for (; i < maxParam; i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (param->isRef()) hasRef = true;
if (param->isOptional()) break;
minParam++;
}
for (i++; i < maxParam; i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (param->isRef()) hasRef = true;
if (!param->isOptional()) {
ar->getCodeError()->record(self, CodeError::RequiredAfterOptionalParam,
param);
param->defaultToNull(ar);
}
}
if (ar->isFirstPass()) {
for (i = 0; i < maxParam; i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (names.find(param->getName()) == names.end()) {
names.insert(param->getName());
} else {
ar->getCodeError()->record(self,
CodeError::RedundantParameter, param);
for (int j = 0; j < 1000; j++) {
string name = param->getName() + lexical_cast<string>(j);
if (names.find(name) == names.end()) {
param->rename(name);
break;
}
}
}
}
}
}
if (hasRef || m_ref) {
m_attribute |= FileScope::ContainsReference;
}
StatementPtr stmt = dynamic_pointer_cast<Statement>(shared_from_this());
FunctionScopePtr funcScope
(new FunctionScope(ar, m_method, m_name, stmt, m_ref, minParam, maxParam,
m_modifiers, m_attribute, m_docComment,
ar->getFileScope()));
if (!m_stmt) {
funcScope->setVirtual();
}
m_funcScope = funcScope;
// TODO: this may have to expand to a concept of "virtual" functions...
if (ar->getClassScope()) {
funcScope->disableInline();
if (m_name.length() > 2 && m_name.substr(0,2) == "__") {
bool magic = true;
int paramCount = 0;
if (m_name == "__destruct") {
funcScope->setOverriding(Type::Variant);
} else if (m_name == "__call") {
funcScope->setOverriding(Type::Variant, Type::String, Type::Array);
paramCount = 2;
} else if (m_name == "__set") {
funcScope->setOverriding(Type::Variant, Type::String, Type::Variant);
paramCount = 2;
} else if (m_name == "__get") {
funcScope->setOverriding(Type::Variant, Type::String);
paramCount = 1;
} else if (m_name == "__isset") {
funcScope->setOverriding(Type::Boolean, Type::String);
paramCount = 1;
} else if (m_name == "__unset") {
funcScope->setOverriding(Type::Variant, Type::String);
paramCount = 1;
} else if (m_name == "__sleep") {
funcScope->setOverriding(Type::Variant);
} else if (m_name == "__wakeup") {
funcScope->setOverriding(Type::Variant);
} else if (m_name == "__set_state") {
funcScope->setOverriding(Type::Variant, Type::Variant);
paramCount = 1;
} else if (m_name == "__tostring") {
funcScope->setOverriding(Type::String);
} else if (m_name == "__clone") {
funcScope->setOverriding(Type::Variant);
} else {
paramCount = -1;
if (m_name != "__construct") {
ar->getCodeError()->record(self, CodeError::UnknownMagicMethod,
//.........这里部分代码省略.........
示例2: onInitialParse
FunctionScopePtr MethodStatement::onInitialParse(AnalysisResultPtr ar,
FileScopePtr fs,
bool method) {
int minParam, maxParam;
ConstructPtr self = shared_from_this();
minParam = maxParam = 0;
bool hasRef = false;
if (m_params) {
set<string> names;
int i = 0;
maxParam = m_params->getCount();
for (; i < maxParam; i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (param->isRef()) hasRef = true;
if (param->isOptional()) break;
minParam++;
}
for (i++; i < maxParam; i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (param->isRef()) hasRef = true;
if (!param->isOptional()) {
Compiler::Error(Compiler::RequiredAfterOptionalParam, param);
param->defaultToNull(ar);
}
}
for (i = 0; i < maxParam; i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (names.find(param->getName()) == names.end()) {
names.insert(param->getName());
} else {
Compiler::Error(Compiler::RedundantParameter, param);
for (int j = 0; j < 1000; j++) {
string name = param->getName() + lexical_cast<string>(j);
if (names.find(name) == names.end()) {
param->rename(name);
break;
}
}
}
}
}
if (hasRef || m_ref) {
m_attribute |= FileScope::ContainsReference;
}
StatementPtr stmt = dynamic_pointer_cast<Statement>(shared_from_this());
FunctionScopePtr funcScope
(new FunctionScope(ar, m_method, m_name, stmt, m_ref, minParam, maxParam,
m_modifiers, m_attribute, m_docComment, fs));
if (!m_stmt) {
funcScope->setVirtual();
}
setBlockScope(funcScope);
return funcScope;
}