本文整理汇总了C++中AnalysisResultPtr::popScope方法的典型用法代码示例。如果您正苦于以下问题:C++ AnalysisResultPtr::popScope方法的具体用法?C++ AnalysisResultPtr::popScope怎么用?C++ AnalysisResultPtr::popScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnalysisResultPtr
的用法示例。
在下文中一共展示了AnalysisResultPtr::popScope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outputPHP
void ClassStatement::outputPHP(CodeGenerator &cg, AnalysisResultPtr ar) {
ClassScopePtr classScope = m_classScope.lock();
if (!classScope->isUserClass()) return;
if (ar) ar->pushScope(classScope);
switch (m_type) {
case T_CLASS: break;
case T_ABSTRACT: cg_printf("abstract "); break;
case T_FINAL: cg_printf("final "); break;
default:
ASSERT(false);
}
cg_printf("class %s", m_name.c_str());
if (!m_parent.empty()) {
cg_printf(" extends %s", m_parent.c_str());
}
if (m_base) {
cg_printf(" implements ");
m_base->outputPHP(cg, ar);
}
cg_indentBegin(" {\n");
m_classScope.lock()->outputPHP(cg, ar);
if (m_stmt) m_stmt->outputPHP(cg, ar);
cg_indentEnd("}\n");
if (ar) ar->popScope();
}
示例2: inferTypes
void BlockScope::inferTypes(AnalysisResultPtr ar) {
if (m_stmt) {
ar->pushScope(shared_from_this());
m_stmt->inferTypes(ar);
ar->popScope();
}
}
示例3: inferTypes
void MethodStatement::inferTypes(AnalysisResultPtr ar) {
FunctionScopePtr funcScope = m_funcScope.lock();
if (ar->getPhase() == AnalysisResult::FirstInference && m_stmt) {
if (m_stmt->hasRetExp() ||
funcScope->inPseudoMain() ||
funcScope->getReturnType()) {
bool lastIsReturn = false;
if (m_stmt->getCount()) {
StatementPtr lastStmt = (*m_stmt)[m_stmt->getCount()-1];
if (lastStmt->is(Statement::KindOfReturnStatement)) {
lastIsReturn = true;
}
}
if (!lastIsReturn &&
!(funcScope->inPseudoMain() && !Option::GenerateCPPMain)) {
ExpressionPtr constant =
funcScope->inPseudoMain() ? CONSTANT("true") : CONSTANT("null");
ReturnStatementPtr returnStmt =
ReturnStatementPtr(new ReturnStatement(getLocation(),
Statement::KindOfReturnStatement, constant));
m_stmt->addElement(returnStmt);
}
}
}
ar->pushScope(funcScope);
if (m_params) {
m_params->inferAndCheck(ar, NEW_TYPE(Any), false);
}
if (m_stmt) {
m_stmt->inferTypes(ar);
}
ar->popScope();
}
示例4: inferTypes
void ClassStatement::inferTypes(AnalysisResultPtr ar) {
if (m_stmt) {
ClassScopePtr classScope = m_classScope.lock();
ar->pushScope(classScope);
m_stmt->inferTypes(ar);
ar->popScope();
}
}
示例5: postOptimize
StatementPtr InterfaceStatement::postOptimize(AnalysisResultPtr ar) {
ar->postOptimize(m_base);
if (m_stmt) {
ClassScopePtr classScope = m_classScope.lock();
ar->pushScope(classScope);
ar->postOptimize(m_stmt);
ar->popScope();
}
return StatementPtr();
}
示例6: onParse
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();
}
}
示例7: preOptimize
StatementPtr InterfaceStatement::preOptimize(AnalysisResultPtr ar) {
ar->preOptimize(m_base);
if (m_stmt) {
ClassScopePtr classScope = m_classScope.lock();
ar->pushScope(classScope);
ar->preOptimize(m_stmt);
ar->popScope();
}
if (ar->getPhase() >= AnalysisResult::AnalyzeAll) {
checkVolatile(ar);
}
return StatementPtr();
}
示例8: inferTypes
void InterfaceStatement::inferTypes(AnalysisResultPtr ar) {
vector<string> bases;
if (m_base) m_base->getStrings(bases);
for (unsigned int i = 0; i < bases.size(); i++) {
addUserClass(ar, bases[i]);
}
if (m_stmt) {
ClassScopePtr classScope = m_classScope.lock();
ar->pushScope(classScope);
m_stmt->inferTypes(ar);
ar->popScope();
}
}
示例9: analyzeProgramImpl
void ClassStatement::analyzeProgramImpl(AnalysisResultPtr ar) {
vector<string> bases;
if (!m_parent.empty()) bases.push_back(m_parent);
if (m_base) m_base->getStrings(bases);
for (unsigned int i = 0; i < bases.size(); i++) {
string className = bases[i];
addUserClass(ar, bases[i]);
}
ClassScopePtr classScope = m_classScope.lock();
if (hasHphpNote("Volatile")) {
classScope->setVolatile();
}
checkVolatile(ar);
if (m_stmt) {
ar->pushScope(classScope);
m_stmt->analyzeProgram(ar);
ar->popScope();
}
if (ar->getPhase() != AnalysisResult::AnalyzeAll) return;
DependencyGraphPtr dependencies = ar->getDependencyGraph();
for (unsigned int i = 0; i < bases.size(); i++) {
ClassScopePtr cls = ar->findClass(bases[i]);
if (cls) {
if ((!cls->isInterface() && (m_parent.empty() || i > 0 )) ||
(cls->isInterface() && (!m_parent.empty() && i == 0 ))) {
ar->getCodeError()->record(CodeError::InvalidDerivation,
shared_from_this(), ConstructPtr(),
cls->getOriginalName().c_str());
}
if (dependencies->checkCircle(DependencyGraph::KindOfClassDerivation,
m_originalName,
cls->getOriginalName())) {
ar->getCodeError()->record(CodeError::InvalidDerivation,
shared_from_this(), ConstructPtr(),
cls->getOriginalName().c_str());
m_parent = "";
m_base = ExpressionListPtr();
classScope->clearBases();
} else if (cls->isUserClass()) {
dependencies->add(DependencyGraph::KindOfClassDerivation,
ar->getName(),
m_originalName, shared_from_this(),
cls->getOriginalName(), cls->getStmt());
}
}
}
}
示例10: outputPHP
void FunctionStatement::outputPHP(CodeGenerator &cg, AnalysisResultPtr ar) {
FunctionScopePtr funcScope = m_funcScope.lock();
if (!funcScope->isUserFunction()) return;
if (ar) ar->pushScope(funcScope);
cg_printf("function ");
if (m_ref) cg_printf("&");
cg_printf("%s(", m_name.c_str());
if (m_params) m_params->outputPHP(cg, ar);
cg_indentBegin(") {\n");
m_funcScope.lock()->outputPHP(cg, ar);
if (m_stmt) m_stmt->outputPHP(cg, ar);
cg_indentEnd("}\n");
if (ar) ar->popScope();
}
示例11: analyzeProgramImpl
void MethodStatement::analyzeProgramImpl(AnalysisResultPtr ar) {
FunctionScopePtr funcScope = m_funcScope.lock();
// registering myself as a parent in dependency graph, so that
// (1) we can tell orphaned parents
// (2) overwrite non-master copy of function declarations
if (ar->isFirstPass()) {
ar->getDependencyGraph()->addParent(DependencyGraph::KindOfFunctionCall,
"", getFullName(), shared_from_this());
if (Option::AllDynamic || hasHphpNote("Dynamic") ||
funcScope->isSepExtension() ||
BuiltinSymbols::IsDeclaredDynamic(m_name) ||
Option::IsDynamicFunction(m_method, m_name)) {
funcScope->setDynamic();
}
if (hasHphpNote("Volatile")) funcScope->setVolatile();
}
funcScope->setIncludeLevel(ar->getIncludeLevel());
ar->pushScope(funcScope);
if (m_params) {
m_params->analyzeProgram(ar);
if (Option::GenRTTIProfileData &&
ar->getPhase() == AnalysisResult::AnalyzeFinal) {
addParamRTTI(ar);
}
}
if (m_stmt) m_stmt->analyzeProgram(ar);
if (ar->isFirstPass()) {
if (!funcScope->isStatic() && ar->getClassScope() &&
funcScope->getVariables()->
getAttribute(VariableTable::ContainsDynamicVariable)) {
// Add this to variable table if we'll need it in a lookup table
// Use object because there's no point to specializing, just makes
// code gen harder when dealing with redeclared classes.
TypePtr tp(NEW_TYPE(Object));
funcScope->getVariables()->add("this", tp, true, ar, shared_from_this(),
ModifierExpressionPtr());
}
FunctionScope::RecordRefParamInfo(m_name, funcScope);
}
ar->popScope();
}
示例12: analyzeProgram
void ClassStatement::analyzeProgram(AnalysisResultPtr ar) {
vector<string> bases;
if (!m_parent.empty()) bases.push_back(m_parent);
if (m_base) m_base->getStrings(bases);
for (unsigned int i = 0; i < bases.size(); i++) {
string className = bases[i];
addUserClass(ar, bases[i]);
}
ClassScopePtr classScope = m_classScope.lock();
if (hasHphpNote("Volatile")) classScope->setVolatile();
FunctionScopePtr func = ar->getFunctionScope();
// redeclared classes are automatically volatile
if (classScope->isVolatile()) {
func->getVariables()->setAttribute(VariableTable::NeedGlobalPointer);
}
if (m_stmt) {
ar->pushScope(classScope);
m_stmt->analyzeProgram(ar);
ar->popScope();
}
DependencyGraphPtr dependencies = ar->getDependencyGraph();
for (unsigned int i = 0; i < bases.size(); i++) {
ClassScopePtr cls = ar->findClass(bases[i]);
if (cls) {
if (dependencies->checkCircle(DependencyGraph::KindOfClassDerivation,
m_originalName,
cls->getOriginalName())) {
ClassScopePtr classScope = m_classScope.lock();
ar->getCodeError()->record(CodeError::InvalidDerivation,
shared_from_this(), ConstructPtr(),
cls->getOriginalName());
m_parent = "";
m_base = ExpressionListPtr();
classScope->clearBases();
} else if (cls->isUserClass()) {
dependencies->add(DependencyGraph::KindOfClassDerivation,
ar->getName(),
m_originalName, shared_from_this(),
cls->getOriginalName(), cls->getStmt());
}
}
}
}
示例13: analyzeProgramImpl
void InterfaceStatement::analyzeProgramImpl(AnalysisResultPtr ar) {
ClassScopePtr classScope = m_classScope.lock();
if (hasHphpNote("Volatile")) classScope->setVolatile();
if (m_stmt) {
classScope->setIncludeLevel(ar->getIncludeLevel());
ar->pushScope(classScope);
m_stmt->analyzeProgram(ar);
ar->popScope();
}
ar->recordClassSource(m_name, ar->getFileScope()->getName());
checkVolatile(ar);
if (ar->getPhase() != AnalysisResult::AnalyzeAll) return;
vector<string> bases;
if (m_base) m_base->getStrings(bases);
DependencyGraphPtr dependencies = ar->getDependencyGraph();
for (unsigned int i = 0; i < bases.size(); i++) {
ClassScopePtr cls = ar->findClass(bases[i]);
if (cls) {
if (!cls->isInterface()) {
ar->getCodeError()->record(CodeError::InvalidDerivation,
shared_from_this(), ConstructPtr(),
cls->getOriginalName());
}
if (dependencies->checkCircle(DependencyGraph::KindOfClassDerivation,
m_originalName,
cls->getOriginalName())) {
ClassScopePtr classScope = m_classScope.lock();
ar->getCodeError()->record(CodeError::InvalidDerivation,
shared_from_this(), ConstructPtr(),
cls->getOriginalName());
m_base = ExpressionListPtr();
classScope->clearBases();
} else if (cls->isUserClass()) {
dependencies->add(DependencyGraph::KindOfClassDerivation,
ar->getName(),
m_originalName, shared_from_this(),
cls->getOriginalName(), cls->getStmt());
}
}
}
}
示例14: outputPHP
void MethodStatement::outputPHP(CodeGenerator &cg, AnalysisResultPtr ar) {
FunctionScopePtr funcScope = m_funcScope.lock();
if (ar) ar->pushScope(funcScope);
m_modifiers->outputPHP(cg, ar);
cg.printf(" function ");
if (m_ref) cg.printf("&");
cg.printf("%s(", m_originalName.c_str());
if (m_params) m_params->outputPHP(cg, ar);
if (m_stmt) {
cg.indentBegin(") {\n");
funcScope->outputPHP(cg, ar);
m_stmt->outputPHP(cg, ar);
cg.indentEnd("}\n");
} else {
cg.printf(");\n");
}
if (ar) ar->popScope();
}
示例15: preOptimize
StatementPtr MethodStatement::preOptimize(AnalysisResultPtr ar) {
ar->preOptimize(m_modifiers);
ar->preOptimize(m_params);
FunctionScopePtr funcScope = m_funcScope.lock();
ar->pushScope(funcScope);
if (ar->getPhase() != AnalysisResult::AnalyzeInclude &&
AliasManager::doLocalCopyProp()) {
bool flag;
do {
AliasManager am;
MethodStatementPtr self =
static_pointer_cast<MethodStatement>(shared_from_this());
flag = am.optimize(ar, self);
ar->preOptimize(m_stmt);
} while (flag);
} else {
ar->preOptimize(m_stmt);
}
ar->popScope();
return StatementPtr();
}