本文整理汇总了C++中FunctionScopePtr::setMagicMethod方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionScopePtr::setMagicMethod方法的具体用法?C++ FunctionScopePtr::setMagicMethod怎么用?C++ FunctionScopePtr::setMagicMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionScopePtr
的用法示例。
在下文中一共展示了FunctionScopePtr::setMagicMethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onParseImpl
//.........这里部分代码省略.........
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,
self);
magic = false;
}
}
if (paramCount >= 0 &&
(paramCount != minParam || paramCount != maxParam)) {
ar->getCodeError()->record(self, CodeError::InvalidMagicMethod,
self);
magic = false;
}
if (magic) funcScope->setMagicMethod();
}
// ArrayAccess methods
else if (m_name.length() > 6 && m_name.substr(0, 6) == "offset") {
if (m_name == "offsetexists") {
funcScope->setOverriding(Type::Boolean, Type::Variant);
} else if (m_name == "offsetget") {
funcScope->setOverriding(Type::Variant, Type::Variant);
} else if (m_name == "offsetset") {
funcScope->setOverriding(Type::Variant, Type::Variant, Type::Variant);
} else if (m_name == "offsetunset") {
funcScope->setOverriding(Type::Variant, Type::Variant);
}
}
}
return funcScope;
}