本文整理汇总了C++中IParseHandlerPtr类的典型用法代码示例。如果您正苦于以下问题:C++ IParseHandlerPtr类的具体用法?C++ IParseHandlerPtr怎么用?C++ IParseHandlerPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IParseHandlerPtr类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ClassScope
void InterfaceStatement::onParse(AnalysisResultConstPtr ar,
FileScopePtr scope) {
vector<string> bases;
if (m_base) m_base->getOriginalStrings(bases);
StatementPtr stmt = dynamic_pointer_cast<Statement>(shared_from_this());
vector<UserAttributePtr> attrs;
if (m_attrList) {
for (int i = 0; i < m_attrList->getCount(); ++i) {
UserAttributePtr a =
dynamic_pointer_cast<UserAttribute>((*m_attrList)[i]);
attrs.push_back(a);
}
}
ClassScopePtr classScope
(new ClassScope(ClassScope::KindOfInterface, m_name, "", bases,
m_docComment, stmt, attrs));
setBlockScope(classScope);
scope->addClass(ar, classScope);
if (Option::PersistenceHook) {
classScope->setPersistent(Option::PersistenceHook(classScope, scope));
}
if (m_stmt) {
for (int i = 0; i < m_stmt->getCount(); i++) {
IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>((*m_stmt)[i]);
ph->onParseRecur(ar, classScope);
}
}
}
示例2: onParse
void ClassVariable::onParse(AnalysisResultPtr ar) {
ModifierExpressionPtr modifiers =
ar->getScope()->setModifiers(m_modifiers);
for (int i = 0; i < m_declaration->getCount(); i++) {
VariableTablePtr variables = ar->getScope()->getVariables();
ExpressionPtr exp = (*m_declaration)[i];
if (exp->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
ExpressionPtr var = assignment->getVariable();
const std::string &name =
dynamic_pointer_cast<SimpleVariable>(var)->getName();
if (variables->isPresent(name)) {
ar->getCodeError()->record(CodeError::DeclaredVariableTwice, exp);
}
IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>(exp);
ph->onParse(ar);
} else {
const std::string &name =
dynamic_pointer_cast<SimpleVariable>(exp)->getName();
if (variables->isPresent(name)) {
ar->getCodeError()->record(CodeError::DeclaredVariableTwice, exp);
}
variables->add(name, TypePtr(), false, ar, exp, m_modifiers);
}
}
ar->getScope()->setModifiers(modifiers);
}
示例3: switch
void ClassStatement::onParse(AnalysisResultPtr ar) {
ClassScope::KindOf kindOf = ClassScope::KindOfObjectClass;
switch (m_type) {
case T_CLASS: kindOf = ClassScope::KindOfObjectClass; break;
case T_ABSTRACT: kindOf = ClassScope::KindOfAbstractClass; break;
case T_FINAL: kindOf = ClassScope::KindOfFinalClass; break;
default:
ASSERT(false);
}
vector<string> bases;
if (!m_parent.empty()) {
bases.push_back(m_parent);
ar->addNonFinal(m_parent);
}
if (m_base) m_base->getStrings(bases);
StatementPtr stmt = dynamic_pointer_cast<Statement>(shared_from_this());
ClassScopePtr classScope(new ClassScope(kindOf, m_originalName, m_parent,
bases, m_docComment,
stmt, ar->getFileScope()));
m_classScope = classScope;
if (!ar->getFileScope()->addClass(ar, classScope)) {
m_ignored = true;
return;
}
ar->recordClassSource(m_name, ar->getFileScope()->getName());
if (m_stmt) {
ar->pushScope(classScope);
bool seenConstruct = false;
for (int i = 0; i < m_stmt->getCount(); i++) {
MethodStatementPtr meth =
dynamic_pointer_cast<MethodStatement>((*m_stmt)[i]);
if (meth && meth->getName() == "__construct") {
seenConstruct = true;
break;
}
}
for (int i = 0; i < m_stmt->getCount(); i++) {
if (!seenConstruct) {
MethodStatementPtr meth =
dynamic_pointer_cast<MethodStatement>((*m_stmt)[i]);
if (meth && classScope && meth->getName() == classScope->getName()
&& !meth->getModifiers()->isStatic()) {
// class-name constructor
classScope->setAttribute(ClassScope::classNameConstructor);
}
}
IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>((*m_stmt)[i]);
ph->onParse(ar);
}
ar->popScope();
}
}
示例4: ClassScope
void InterfaceStatement::onParse(AnalysisResultPtr ar, BlockScopePtr scope) {
vector<string> bases;
if (m_base) m_base->getStrings(bases);
FileScopePtr fs = dynamic_pointer_cast<FileScope>(scope);
StatementPtr stmt = dynamic_pointer_cast<Statement>(shared_from_this());
ClassScopePtr classScope
(new ClassScope(ClassScope::KindOfInterface, m_name, "", bases,
m_docComment, stmt));
setBlockScope(classScope);
fs->addClass(ar, classScope);
if (m_stmt) {
for (int i = 0; i < m_stmt->getCount(); i++) {
IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>((*m_stmt)[i]);
ph->onParse(ar, classScope);
}
}
}
示例5: classScope
void InterfaceStatement::onParse(AnalysisResultPtr ar) {
vector<string> bases;
if (m_base) m_base->getStrings(bases);
StatementPtr stmt = dynamic_pointer_cast<Statement>(shared_from_this());
ClassScopePtr classScope(new ClassScope(ClassScope::KindOfInterface,
m_name, "", bases, m_docComment, stmt,
ar->getFileScope()));
m_classScope = classScope;
ar->getFileScope()->addClass(ar, classScope);
ar->getDependencyGraph()->addParent(DependencyGraph::KindOfProgramUserClass,
"", m_originalName, stmt);
if (m_stmt) {
ar->pushScope(classScope);
for (int i = 0; i < m_stmt->getCount(); i++) {
IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>((*m_stmt)[i]);
ph->onParse(ar);
}
ar->popScope();
}
}
示例6: setBlockScope
void InterfaceStatement::onParse(AnalysisResultConstPtr ar,
FileScopePtr scope) {
vector<string> bases;
if (m_base) m_base->getStrings(bases);
for (auto &b : bases) {
ar->parseOnDemandByClass(b);
}
StatementPtr stmt = dynamic_pointer_cast<Statement>(shared_from_this());
vector<UserAttributePtr> attrs;
if (m_attrList) {
for (int i = 0; i < m_attrList->getCount(); ++i) {
UserAttributePtr a =
dynamic_pointer_cast<UserAttribute>((*m_attrList)[i]);
attrs.push_back(a);
}
}
auto classScope =
std::make_shared<ClassScope>(
scope, ClassScope::KindOf::Interface, m_originalName, "", bases,
m_docComment, stmt, attrs);
setBlockScope(classScope);
scope->addClass(ar, classScope);
classScope->setPersistent(false);
if (m_stmt) {
for (int i = 0; i < m_stmt->getCount(); i++) {
IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>((*m_stmt)[i]);
ph->onParseRecur(ar, scope, classScope);
}
checkArgumentsToPromote(scope, ExpressionListPtr(), T_INTERFACE);
}
}
示例7: switch
void ClassStatement::onParse(AnalysisResultConstPtr ar, FileScopePtr fs) {
ClassScope::KindOf kindOf = ClassScope::KindOfObjectClass;
switch (m_type) {
case T_CLASS: kindOf = ClassScope::KindOfObjectClass; break;
case T_ABSTRACT: kindOf = ClassScope::KindOfAbstractClass; break;
case T_FINAL: kindOf = ClassScope::KindOfFinalClass; break;
default:
ASSERT(false);
}
vector<string> bases;
if (!m_parent.empty()) {
bases.push_back(m_parent);
}
if (m_base) m_base->getStrings(bases);
StatementPtr stmt = dynamic_pointer_cast<Statement>(shared_from_this());
ClassScopePtr classScope(new ClassScope(kindOf, m_originalName, m_parent,
bases, m_docComment,
stmt));
setBlockScope(classScope);
if (!fs->addClass(ar, classScope)) {
m_ignored = true;
return;
}
if (m_stmt) {
bool seenConstruct = false;
// flatten continuation StatementList into MethodStatements
for (int i = 0; i < m_stmt->getCount(); i++) {
StatementListPtr stmts =
dynamic_pointer_cast<StatementList>((*m_stmt)[i]);
if (stmts) {
m_stmt->removeElement(i);
for (int j = 0; j < stmts->getCount(); j++) {
m_stmt->insertElement((*stmts)[j], i + j);
}
}
}
for (int i = 0; i < m_stmt->getCount(); i++) {
MethodStatementPtr meth =
dynamic_pointer_cast<MethodStatement>((*m_stmt)[i]);
if (meth && meth->getName() == "__construct") {
seenConstruct = true;
break;
}
}
for (int i = 0; i < m_stmt->getCount(); i++) {
if (!seenConstruct) {
MethodStatementPtr meth =
dynamic_pointer_cast<MethodStatement>((*m_stmt)[i]);
if (meth && classScope && meth->getName() == classScope->getName()
&& !meth->getModifiers()->isStatic()) {
// class-name constructor
classScope->setAttribute(ClassScope::ClassNameConstructor);
}
}
IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>((*m_stmt)[i]);
ph->onParseRecur(ar, classScope);
}
}
}
示例8: switch
void ClassStatement::onParse(AnalysisResultConstPtr ar, FileScopePtr fs) {
ClassScope::KindOf kindOf = ClassScope::KindOfObjectClass;
switch (m_type) {
case T_CLASS: kindOf = ClassScope::KindOfObjectClass; break;
case T_ABSTRACT: kindOf = ClassScope::KindOfAbstractClass; break;
case T_FINAL: kindOf = ClassScope::KindOfFinalClass; break;
case T_TRAIT: kindOf = ClassScope::KindOfTrait; break;
default:
assert(false);
}
vector<string> bases;
if (!m_originalParent.empty()) {
bases.push_back(m_originalParent);
}
if (m_base) m_base->getOriginalStrings(bases);
for (auto &b : bases) {
ar->parseOnDemandByClass(Util::toLower(b));
}
vector<UserAttributePtr> attrs;
if (m_attrList) {
for (int i = 0; i < m_attrList->getCount(); ++i) {
UserAttributePtr a =
dynamic_pointer_cast<UserAttribute>((*m_attrList)[i]);
attrs.push_back(a);
}
}
StatementPtr stmt = dynamic_pointer_cast<Statement>(shared_from_this());
ClassScopePtr classScope(new ClassScope(kindOf, m_originalName,
m_originalParent,
bases, m_docComment,
stmt, attrs));
setBlockScope(classScope);
if (!fs->addClass(ar, classScope)) {
m_ignored = true;
return;
}
if (Option::PersistenceHook) {
classScope->setPersistent(Option::PersistenceHook(classScope, fs));
}
if (m_stmt) {
MethodStatementPtr constructor;
// flatten continuation StatementList into MethodStatements
for (int i = 0; i < m_stmt->getCount(); i++) {
StatementListPtr stmts =
dynamic_pointer_cast<StatementList>((*m_stmt)[i]);
if (stmts) {
m_stmt->removeElement(i);
for (int j = 0; j < stmts->getCount(); j++) {
m_stmt->insertElement((*stmts)[j], i + j);
}
}
}
for (int i = 0; i < m_stmt->getCount(); i++) {
MethodStatementPtr meth =
dynamic_pointer_cast<MethodStatement>((*m_stmt)[i]);
if (meth && meth->getName() == "__construct") {
constructor = meth;
break;
}
}
for (int i = 0; i < m_stmt->getCount(); i++) {
if (!constructor) {
MethodStatementPtr meth =
dynamic_pointer_cast<MethodStatement>((*m_stmt)[i]);
if (meth && meth->getName() == classScope->getName()
&& !classScope->isTrait()) {
// class-name constructor
constructor = meth;
classScope->setAttribute(ClassScope::ClassNameConstructor);
}
}
IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>((*m_stmt)[i]);
ph->onParseRecur(ar, classScope);
}
if (constructor && constructor->getModifiers()->isStatic()) {
constructor->parseTimeFatal(Compiler::InvalidAttribute,
"Constructor %s::%s() cannot be static",
classScope->getOriginalName().c_str(),
constructor->getOriginalName().c_str());
}
}
}
示例9: switch
void ClassStatement::onParse(AnalysisResultConstPtr ar, FileScopePtr fs) {
ClassScope::KindOf kindOf = ClassScope::KindOf::ObjectClass;
switch (m_type) {
case T_CLASS: kindOf = ClassScope::KindOf::ObjectClass; break;
case T_ABSTRACT: kindOf = ClassScope::KindOf::AbstractClass; break;
case T_STATIC: // Slight hack: see comments in hphp.y
kindOf = ClassScope::KindOf::UtilClass; break;
case T_FINAL: kindOf = ClassScope::KindOf::FinalClass; break;
case T_TRAIT: kindOf = ClassScope::KindOf::Trait; break;
case T_ENUM: kindOf = ClassScope::KindOf::Enum; break;
default:
assert(false);
}
std::vector<std::string> bases;
if (!m_originalParent.empty()) {
bases.push_back(m_originalParent);
}
if (m_base) m_base->getStrings(bases);
for (auto &b : bases) {
ar->parseOnDemandByClass(b);
}
std::vector<UserAttributePtr> attrs;
if (m_attrList) {
for (int i = 0; i < m_attrList->getCount(); ++i) {
UserAttributePtr a =
dynamic_pointer_cast<UserAttribute>((*m_attrList)[i]);
attrs.push_back(a);
}
}
StatementPtr stmt = dynamic_pointer_cast<Statement>(shared_from_this());
auto classScope = std::make_shared<ClassScope>(
fs, kindOf, m_originalName,
m_originalParent,
bases, m_docComment,
stmt, attrs);
setBlockScope(classScope);
if (!fs->addClass(ar, classScope)) {
m_ignored = true;
return;
}
classScope->setPersistent(false);
if (m_stmt) {
MethodStatementPtr constructor = nullptr;
MethodStatementPtr destructor = nullptr;
MethodStatementPtr clone = nullptr;
// flatten continuation StatementList into MethodStatements
for (int i = 0; i < m_stmt->getCount(); i++) {
StatementListPtr stmts =
dynamic_pointer_cast<StatementList>((*m_stmt)[i]);
if (stmts) {
m_stmt->removeElement(i);
for (int j = 0; j < stmts->getCount(); j++) {
m_stmt->insertElement((*stmts)[j], i + j);
}
}
}
for (int i = 0; i < m_stmt->getCount(); i++) {
MethodStatementPtr meth =
dynamic_pointer_cast<MethodStatement>((*m_stmt)[i]);
if (meth) {
if (meth->isNamed("__construct")) {
constructor = meth;
continue;
}
if (meth->isNamed("__destruct")) {
destructor = meth;
continue;
}
if (meth->isNamed("__clone")) {
clone = meth;
continue;
}
}
if (constructor && destructor && clone) {
break;
}
}
for (int i = 0; i < m_stmt->getCount(); i++) {
if (!constructor) {
MethodStatementPtr meth =
dynamic_pointer_cast<MethodStatement>((*m_stmt)[i]);
if (meth &&
meth->isNamed(classScope->getOriginalName()) &&
!classScope->isTrait()) {
// class-name constructor
constructor = meth;
classScope->setAttribute(ClassScope::ClassNameConstructor);
}
}
IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>((*m_stmt)[i]);
//.........这里部分代码省略.........
示例10: onParse
void ClassConstant::onParse(AnalysisResultPtr ar) {
for (int i = 0; i < m_exp->getCount(); i++) {
IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>((*m_exp)[i]);
ph->onParse(ar);
}
}