本文整理汇总了C++中ParameterExpressionPtr::compatibleDefault方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterExpressionPtr::compatibleDefault方法的具体用法?C++ ParameterExpressionPtr::compatibleDefault怎么用?C++ ParameterExpressionPtr::compatibleDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterExpressionPtr
的用法示例。
在下文中一共展示了ParameterExpressionPtr::compatibleDefault方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onParse
void FunctionStatement::onParse(AnalysisResultConstPtr ar, FileScopePtr scope) {
// Correctness checks are normally done before adding function to scope.
if (m_params) {
for (int i = 0; i < m_params->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (param->hasTypeHint() && param->defaultValue()) {
param->compatibleDefault();
}
}
}
// note it's important to add to scope, not a pushed FunctionContainer,
// as a function may be declared inside a class's method, yet this function
// is a global function, not a class method.
FunctionScopePtr fs = onInitialParse(ar, scope);
FunctionScope::RecordFunctionInfo(m_name, fs);
if (!scope->addFunction(ar, fs)) {
m_ignored = true;
return;
}
if (Option::PersistenceHook) {
fs->setPersistent(Option::PersistenceHook(fs, scope));
}
}
示例2: onParse
void FunctionStatement::onParse(AnalysisResultConstPtr ar, FileScopePtr scope) {
// Correctness checks are normally done before adding function to scope.
if (m_params) {
for (int i = 0; i < m_params->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (param->hasTypeHint() && param->defaultValue()) {
param->compatibleDefault();
}
}
}
// note it's important to add to scope, not a pushed FunctionContainer,
// as a function may be declared inside a class's method, yet this function
// is a global function, not a class method.
FunctionScopePtr fs = onInitialParse(ar, scope);
FunctionScope::RecordFunctionInfo(m_name, fs);
if (!scope->addFunction(ar, fs)) {
m_ignored = true;
return;
}
if (Option::PersistenceHook) {
fs->setPersistent(Option::PersistenceHook(fs, scope));
}
if (fs->isNative()) {
if (getStmts()) {
parseTimeFatal(Compiler::InvalidAttribute,
"Native functions must not have an implementation body");
}
if (m_params) {
int nParams = m_params->getCount();
for (int i = 0; i < nParams; ++i) {
auto param = dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (!param->hasUserType()) {
parseTimeFatal(Compiler::InvalidAttribute,
"Native function calls must have type hints "
"on all args");
}
}
}
if (getReturnTypeConstraint().empty()) {
parseTimeFatal(Compiler::InvalidAttribute,
"Native function %s() must have a return type hint",
getOriginalName().c_str());
}
} else if (!getStmts()) {
parseTimeFatal(Compiler::InvalidAttribute,
"Global function %s() must contain a body",
getOriginalName().c_str());
}
}
示例3: onParse
void FunctionStatement::onParse(AnalysisResultConstPtr ar, FileScopePtr scope) {
checkParameters(scope);
// Correctness checks are normally done before adding function to scope.
if (m_params) {
for (int i = 0; i < m_params->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (param->hasTypeHint() && param->defaultValue()) {
param->compatibleDefault(scope);
}
}
}
// note it's important to add to scope, not a pushed FunctionContainer,
// as a function may be declared inside a class's method, yet this function
// is a global function, not a class method.
FunctionScopePtr fs = onInitialParse(ar, scope);
FunctionScope::RecordFunctionInfo(m_originalName, fs);
if (!scope->addFunction(ar, fs)) {
m_ignored = true;
return;
}
fs->setPersistent(false);
if (isNamed("__autoload")) {
if (m_params && m_params->getCount() != 1) {
parseTimeFatal(scope,
Compiler::InvalidMagicMethod,
"__autoload() must take exactly 1 argument");
}
}
if (fs->isNative()) {
if (getStmts()) {
parseTimeFatal(scope,
Compiler::InvalidAttribute,
"Native functions must not have an implementation body");
}
if (m_params) {
int nParams = m_params->getCount();
for (int i = 0; i < nParams; ++i) {
// Variadic capture params don't need types
// since they'll be Arrays as far as HNI is concerned.
auto param = dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (!param->hasUserType() && !param->isVariadic()) {
parseTimeFatal(scope,
Compiler::InvalidAttribute,
"Native function calls must have type hints "
"on all args");
}
}
}
if (getReturnTypeConstraint().empty()) {
parseTimeFatal(scope,
Compiler::InvalidAttribute,
"Native function %s() must have a return type hint",
getOriginalName().c_str());
}
} else if (!getStmts()) {
parseTimeFatal(scope,
Compiler::InvalidAttribute,
"Global function %s() must contain a body",
getOriginalName().c_str());
}
}