本文整理汇总了C++中AnalysisResultPtr::getPhase方法的典型用法代码示例。如果您正苦于以下问题:C++ AnalysisResultPtr::getPhase方法的具体用法?C++ AnalysisResultPtr::getPhase怎么用?C++ AnalysisResultPtr::getPhase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnalysisResultPtr
的用法示例。
在下文中一共展示了AnalysisResultPtr::getPhase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: analyzeProgramImpl
void StatementList::analyzeProgramImpl(AnalysisResultPtr ar) {
m_included = true;
for (unsigned int i = 0; i < m_stmts.size(); i++) {
StatementPtr stmt = m_stmts[i];
// effect testing
if (ar->getPhase() == AnalysisResult::AnalyzeAll) {
if (!stmt->hasEffect() &&
!stmt->is(Statement::KindOfStatementList)) {
Compiler::Error(Compiler::StatementHasNoEffect, stmt);
}
if (stmt->is(Statement::KindOfExpStatement)) {
static_pointer_cast<ExpStatement>(stmt)->analyzeShortCircuit(ar);
}
}
bool scopeStmt = stmt->is(Statement::KindOfFunctionStatement) ||
stmt->is(Statement::KindOfClassStatement) ||
stmt->is(Statement::KindOfInterfaceStatement);
if (ar->getPhase() != AnalysisResult::AnalyzeTopLevel || !scopeStmt) {
/* Recurse when analyzing include/all OR when not a scope */
stmt->analyzeProgram(ar);
}
}
}
示例2: analyzeProgram
void ObjectMethodExpression::analyzeProgram(AnalysisResultPtr ar) {
FunctionCall::analyzeProgram(ar);
m_object->analyzeProgram(ar);
if (ar->getPhase() == AnalysisResult::AnalyzeAll) {
FunctionScopePtr func = m_funcScope;
if (!func && m_object->isThis() && !m_name.empty()) {
ClassScopePtr cls = getClassScope();
if (cls) {
m_classScope = cls;
m_funcScope = func = cls->findFunction(ar, m_name, true, true);
if (!func) {
cls->addMissingMethod(m_name);
} else {
func->addCaller(getScope());
}
}
}
markRefParams(func, m_name, canInvokeFewArgs());
}
// This is OK because AnalyzeFinal is guaranteed to run for a CPP
// target, regardless of opts (and we only need the following
// for CPP targets)
if (ar->getPhase() == AnalysisResult::AnalyzeFinal) {
// necessary because we set the expected type of m_object to
// Type::Some during type inference.
TypePtr act(m_object->getActualType());
if (!m_object->isThis() && act && act->is(Type::KindOfObject)) {
m_object->setExpectedType(act);
}
}
}
示例3: analyzeProgramImpl
void StatementList::analyzeProgramImpl(AnalysisResultPtr ar) {
m_included = true;
for (unsigned int i = 0; i < m_stmts.size(); i++) {
StatementPtr stmt = m_stmts[i];
// effect testing
if (ar->isFirstPass() && !stmt->hasEffect() &&
!stmt->is(Statement::KindOfStatementList)) {
ar->getCodeError()->record(shared_from_this(),
CodeError::StatementHasNoEffect, stmt);
}
// changing AUTOLOAD to includes
if (ar->getPhase() == AnalysisResult::AnalyzeInclude &&
stmt->is(Statement::KindOfExpStatement)) {
ExpStatementPtr expStmt = dynamic_pointer_cast<ExpStatement>(stmt);
if (stmt->isFileLevel()) {
expStmt->analyzeAutoload(ar);
}
expStmt->analyzeShortCircuit(ar);
}
bool scopeStmt = stmt->is(Statement::KindOfFunctionStatement) ||
stmt->is(Statement::KindOfClassStatement) ||
stmt->is(Statement::KindOfInterfaceStatement);
if (ar->getPhase() != AnalysisResult::AnalyzeTopLevel || !scopeStmt) {
/* Recurse when analyzing include/all OR when not a scope */
stmt->analyzeProgram(ar);
}
}
}
示例4: analyzeProgram
void NewObjectExpression::analyzeProgram(AnalysisResultPtr ar) {
FunctionCall::analyzeProgram(ar);
if (ar->getPhase() == AnalysisResult::AnalyzeAll ||
ar->getPhase() == AnalysisResult::AnalyzeFinal) {
FunctionScopePtr func;
if (!m_name.empty()) {
if (ClassScopePtr cls = resolveClass()) {
m_name = m_className;
func = cls->findConstructor(ar, true);
if (func) func->addNewObjCaller(getScope());
}
}
if (m_params) {
markRefParams(func, "", canInvokeFewArgs());
}
if (ar->getPhase() == AnalysisResult::AnalyzeFinal) {
TypePtr at(getActualType());
if (at && at->isSpecificObject() && !getExpectedType()) {
setExpectedType(at);
}
}
}
}
示例5: analyzeProgram
void ClosureExpression::analyzeProgram(AnalysisResultPtr ar) {
m_func->analyzeProgram(ar);
if (m_vars) {
m_values->analyzeProgram(ar);
if (ar->getPhase() == AnalysisResult::AnalyzeAll) {
getFunctionScope()->addUse(m_func->getFunctionScope(),
BlockScope::UseKindClosure);
m_func->getFunctionScope()->setClosureVars(m_vars);
// closure function's variable table (not containing function's)
VariableTablePtr variables = m_func->getFunctionScope()->getVariables();
VariableTablePtr containing = getFunctionScope()->getVariables();
for (int i = 0; i < m_vars->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
const string &name = param->getName();
{
Symbol *containingSym = containing->addDeclaredSymbol(name, param);
containingSym->setPassClosureVar();
Symbol *sym = variables->addDeclaredSymbol(name, param);
sym->setClosureVar();
sym->setDeclaration(ConstructPtr());
if (param->isRef()) {
sym->setRefClosureVar();
sym->setUsed();
} else {
sym->clearRefClosureVar();
sym->clearUsed();
}
}
}
return;
}
if (ar->getPhase() == AnalysisResult::AnalyzeFinal) {
// closure function's variable table (not containing function's)
VariableTablePtr variables = m_func->getFunctionScope()->getVariables();
for (int i = 0; i < m_vars->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
const string &name = param->getName();
// so we can assign values to them, instead of seeing CVarRef
Symbol *sym = variables->getSymbol(name);
if (sym && sym->isParameter()) {
sym->setLvalParam();
}
}
}
}
FunctionScopeRawPtr container =
getFunctionScope()->getContainingNonClosureFunction();
if (container && container->isStatic()) {
m_func->getModifiers()->add(T_STATIC);
}
}
示例6: addUserClass
void Construct::addUserClass(AnalysisResultPtr ar,
const std::string &name) {
if (!name.empty()) {
if (ar->getPhase() == AnalysisResult::AnalyzeAll ||
ar->getPhase() == AnalysisResult::AnalyzeFinal) {
getFileScope()->addClassDependency(ar, name);
}
}
}
示例7: simplifyLogical
ExpressionPtr BinaryOpExpression::simplifyLogical(AnalysisResultPtr ar) {
if (m_exp1->is(Expression::KindOfConstantExpression)) {
ConstantExpressionPtr con =
dynamic_pointer_cast<ConstantExpression>(m_exp1);
if (con->isBoolean()) {
if (con->getBooleanValue()) {
if (ar->getPhase() >= AnalysisResult::PostOptimize) {
// true && v (true AND v) => v
ASSERT(m_exp2->getType()->is(Type::KindOfBoolean));
if (m_op == T_BOOLEAN_AND || m_op == T_LOGICAL_AND) return m_exp2;
}
// true || v (true OR v) => true
if (m_op == T_BOOLEAN_OR || m_op == T_LOGICAL_OR) {
return CONSTANT("true");
}
} else {
if (ar->getPhase() >= AnalysisResult::PostOptimize) {
ASSERT(m_exp2->getType()->is(Type::KindOfBoolean));
// false || v (false OR v) => v
if (m_op == T_BOOLEAN_OR || m_op == T_LOGICAL_OR) return m_exp2;
}
// false && v (false AND v) => false
if (m_op == T_BOOLEAN_AND || m_op == T_LOGICAL_AND) {
return CONSTANT("false");
}
}
}
}
if (m_exp2->is(Expression::KindOfConstantExpression)) {
ConstantExpressionPtr con =
dynamic_pointer_cast<ConstantExpression>(m_exp2);
if (con->isBoolean()) {
if (con->getBooleanValue()) {
if (ar->getPhase() >= AnalysisResult::PostOptimize) {
ASSERT(m_exp1->getType()->is(Type::KindOfBoolean));
// v && true (v AND true) => v
if (m_op == T_BOOLEAN_AND || m_op == T_LOGICAL_AND) return m_exp1;
}
// v || true (v OR true) => true when v does not have effect
if (m_op == T_BOOLEAN_OR || m_op == T_LOGICAL_OR) {
if (!m_exp1->hasEffect()) return CONSTANT("true");
}
} else {
if (ar->getPhase() >= AnalysisResult::PostOptimize) {
ASSERT(m_exp1->getType()->is(Type::KindOfBoolean));
// v || false (v OR false) => v
if (m_op == T_BOOLEAN_OR || m_op == T_LOGICAL_OR) return m_exp1;
}
// v && false (v AND false) => false when v does not have effect
if (m_op == T_BOOLEAN_AND || m_op == T_LOGICAL_AND) {
if (!m_exp1->hasEffect()) return CONSTANT("false");
}
}
}
}
return ExpressionPtr();
}
示例8: addUserFunction
void Construct::addUserFunction(AnalysisResultPtr ar,
const std::string &name) {
if (!name.empty()) {
if (ar->getPhase() == AnalysisResult::AnalyzeAll ||
ar->getPhase() == AnalysisResult::AnalyzeFinal) {
FunctionScopePtr func = getFunctionScope();
getFileScope()->addFunctionDependency(ar, name, func &&
func->isInlined());
}
}
}
示例9: analyzeProgram
void UnaryOpExpression::analyzeProgram(AnalysisResultPtr ar) {
if (ar->getPhase() == AnalysisResult::AnalyzeFinal && m_op == '@') {
StatementPtr stmt = ar->getStatementForSilencer();
ASSERT(stmt);
m_silencer = stmt->requireSilencers(1);
}
if (m_exp) m_exp->analyzeProgram(ar);
if (ar->getPhase() == AnalysisResult::AnalyzeFinal && m_op == '@') {
StatementPtr stmt = ar->getStatementForSilencer();
ASSERT(stmt);
stmt->endRequireSilencers(m_silencer);
}
}
示例10: analyzeProgram
void SimpleVariable::analyzeProgram(AnalysisResultPtr ar) {
m_superGlobal = BuiltinSymbols::IsSuperGlobal(m_name);
m_superGlobalType = BuiltinSymbols::GetSuperGlobalType(m_name);
VariableTablePtr variables = getScope()->getVariables();
if (m_superGlobal) {
variables->setAttribute(VariableTable::NeedGlobalPointer);
} else if (m_name == "GLOBALS") {
m_globals = true;
} else {
m_sym = variables->addSymbol(m_name);
}
if (ar->getPhase() == AnalysisResult::AnalyzeAll) {
if (FunctionScopePtr func = getFunctionScope()) {
if (m_name == "this" && getClassScope()) {
func->setContainsThis();
m_this = true;
if (!hasContext(ObjectContext)) {
func->setContainsBareThis();
if (variables->getAttribute(VariableTable::ContainsDynamicVariable)) {
ClassScopePtr cls = getClassScope();
TypePtr t = cls->isRedeclaring() ?
Type::Variant : Type::CreateObjectType(cls->getName());
variables->add(m_sym, t, true, ar, shared_from_this(),
getScope()->getModifiers());
}
}
}
if (m_sym && !(m_context & AssignmentLHS) &&
!((m_context & UnsetContext) && (m_context & LValue))) {
m_sym->setUsed();
}
}
} else if (ar->getPhase() == AnalysisResult::AnalyzeFinal) {
if (m_sym && !m_sym->isSystem() &&
!(getContext() &
(LValue|RefValue|RefParameter|UnsetContext|ExistContext)) &&
m_sym->getDeclaration().get() == this &&
!variables->getAttribute(VariableTable::ContainsLDynamicVariable) &&
!getScope()->is(BlockScope::ClassScope)) {
if (getScope()->inPseudoMain()) {
Compiler::Error(Compiler::UseUndeclaredGlobalVariable,
shared_from_this());
} else {
Compiler::Error(Compiler::UseUndeclaredVariable, shared_from_this());
}
}
}
}
示例11: analyzeProgram
void ObjectMethodExpression::analyzeProgram(AnalysisResultPtr ar) {
FunctionCall::analyzeProgram(ar);
m_object->analyzeProgram(ar);
if (ar->getPhase() == AnalysisResult::AnalyzeAll) {
FunctionScopePtr func = m_funcScope;
if (!func && m_object->isThis() && !m_name.empty()) {
ClassScopePtr cls = getClassScope();
if (cls) {
m_classScope = cls;
func = cls->findFunction(ar, m_name, true, true);
if (func &&
!cls->isInterface() &&
!(func->isVirtual() &&
(func->isAbstract() ||
(func->hasOverride() &&
cls->getAttribute(ClassScope::NotFinal))) &&
!func->isPerfectVirtual())) {
m_funcScope = func;
func->addCaller(getScope());
}
}
}
markRefParams(func, m_name, canInvokeFewArgs());
}
// This is OK because AnalyzeFinal is guaranteed to run for a CPP
// target, regardless of opts (and we only need the following
// for CPP targets)
if (ar->getPhase() == AnalysisResult::AnalyzeFinal) {
// necessary because we set the expected type of m_object to
// Type::Some during type inference.
TypePtr at(m_object->getActualType());
TypePtr it(m_object->getImplementedType());
if (!m_object->isThis() && at && at->is(Type::KindOfObject)) {
if (at->isSpecificObject() && it && Type::IsMappedToVariant(it)) {
// fast-cast inference
ClassScopePtr scope(ar->findClass(at->getName()));
if (scope) {
// add a dependency to m_object's class type
// to allow the fast cast to succeed
addUserClass(ar, at->getName());
}
}
m_object->setExpectedType(at);
}
}
}
示例12: analyzeProgramImpl
void StaticStatement::analyzeProgramImpl(AnalysisResultPtr ar) {
m_exp->analyzeProgram(ar);
BlockScopePtr scope = ar->getScope();
for (int i = 0; i < m_exp->getCount(); i++) {
ExpressionPtr exp = (*m_exp)[i];
ExpressionPtr variable;
ExpressionPtr value;
if (ar->getPhase() == AnalysisResult::AnalyzeInclude) {
// turn static $a; into static $a = null;
if (exp->is(Expression::KindOfSimpleVariable)) {
variable = dynamic_pointer_cast<SimpleVariable>(exp);
exp = AssignmentExpressionPtr
(new AssignmentExpression(exp->getLocation(),
Expression::KindOfAssignmentExpression,
variable,
CONSTANT("null"),
false));
(*m_exp)[i] = exp;
}
}
if (exp->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr assignment_exp =
dynamic_pointer_cast<AssignmentExpression>(exp);
variable = assignment_exp->getVariable();
value = assignment_exp->getValue();
} else {
ASSERT(false);
}
SimpleVariablePtr var = dynamic_pointer_cast<SimpleVariable>(variable);
if (ar->getPhase() == AnalysisResult::AnalyzeInclude) {
if (scope->getVariables()->setStaticInitVal(var->getName(), value)) {
ar->getCodeError()->record(CodeError::DeclaredStaticVariableTwice,
exp);
}
} else if (ar->getPhase() == AnalysisResult::AnalyzeAll) {
// update initial value
const string &name = var->getName();
ExpressionPtr initValue =
(dynamic_pointer_cast<Expression>
(scope->getVariables()->getStaticInitVal(name)))->clone();
exp = AssignmentExpressionPtr
(new AssignmentExpression(exp->getLocation(),
Expression::KindOfAssignmentExpression,
variable, initValue, false));
(*m_exp)[i] = exp;
}
}
}
示例13: preOptimize
ExpressionPtr UnaryOpExpression::preOptimize(AnalysisResultPtr ar) {
Variant value;
Variant result;
if (m_exp && ar->getPhase() >= AnalysisResult::FirstPreOptimize) {
if (m_op == '(') {
return m_exp;
}
if (m_op == T_UNSET) {
if (m_exp->isScalar() ||
(m_exp->is(KindOfExpressionList) &&
static_pointer_cast<ExpressionList>(m_exp)->getCount() == 0)) {
return CONSTANT("null");
}
return ExpressionPtr();
}
}
if (m_op != T_ARRAY &&
m_exp &&
m_exp->isScalar() &&
m_exp->getScalarValue(value) &&
preCompute(value, result)) {
return replaceValue(makeScalarExpression(ar, result));
}
return ExpressionPtr();
}
示例14: analyzeProgram
void ClassStatement::analyzeProgram(AnalysisResultPtr ar) {
std::vector<std::string> bases;
auto const hasParent = !m_originalParent.empty();
if (hasParent) bases.push_back(m_originalParent);
if (m_base) m_base->getStrings(bases);
checkVolatile(ar);
if (m_stmt) {
m_stmt->analyzeProgram(ar);
}
if (ar->getPhase() != AnalysisResult::AnalyzeAll) return;
for (unsigned int i = 0; i < bases.size(); i++) {
ClassScopePtr cls = ar->findClass(bases[i]);
if (cls) {
auto const expectClass = hasParent && i == 0;
if (expectClass == cls->isInterface() || cls->isTrait()) {
Compiler::Error(Compiler::InvalidDerivation,
shared_from_this(),
"You are extending " + cls->getOriginalName() +
" which is an interface or a trait");
}
if (cls->isUserClass()) {
cls->addUse(getScope(), BlockScope::UseKindParentRef);
}
}
}
}
示例15: analyzeInclude
void IncludeExpression::analyzeInclude(AnalysisResultPtr ar,
const std::string &include) {
ASSERT(ar->getPhase() == AnalysisResult::AnalyzeInclude);
ConstructPtr self = shared_from_this();
FileScopePtr file = ar->findFileScope(include, true);
if (!file) {
ar->getCodeError()->record(self, CodeError::PHPIncludeFileNotFound, self);
return;
}
if (include.find("compiler/") != 0 ||
include.find("/compiler/") == string::npos) {
ar->getCodeError()->record(self, CodeError::PHPIncludeFileNotInLib,
self, ConstructPtr(),
include.c_str());
}
if (!isFileLevel()) { // Not unsupported but potentially bad
ar->getCodeError()->record(self, CodeError::UseDynamicInclude, self);
}
ar->getDependencyGraph()->add
(DependencyGraph::KindOfProgramMaxInclude,
ar->getName(), file->getName(), StatementPtr());
ar->getDependencyGraph()->addParent
(DependencyGraph::KindOfProgramMinInclude,
ar->getName(), file->getName(), StatementPtr());
FunctionScopePtr func = ar->getFunctionScope();
ar->getFileScope()->addIncludeDependency(ar, m_include,
func && func->isInlined());
}