bool IncludeExpression::analyzeInclude(AnalysisResultConstPtr ar, const std::string &include) { ConstructPtr self = shared_from_this(); FileScopePtr file = ar->findFileScope(include); if (!file) { Compiler::Error(Compiler::PHPIncludeFileNotFound, self); return false; } FunctionScopePtr func = getFunctionScope(); if (func && file->getPseudoMain()) { file->getPseudoMain()->addUse(func, BlockScope::UseKindInclude); } return true; }
void IncludeExpression::analyzeInclude(AnalysisResultPtr ar, const std::string &include) { ConstructPtr self = shared_from_this(); FileScopePtr file = ar->findFileScope(include); if (!file && !include.empty()) { Compiler::Error(Compiler::PHPIncludeFileNotFound, self); return; } FunctionScopePtr func = getFunctionScope(); getFileScope()->addIncludeDependency(ar, m_include, func && func->isInlined()); if (func && file->getPseudoMain()) { file->getPseudoMain()->addUse(func, BlockScope::UseKindInclude); } }
ExpressionPtr IncludeExpression::postOptimize(AnalysisResultConstPtr ar) { if (!m_include.empty()) { if (!m_depsSet) { analyzeInclude(ar, m_include); m_depsSet = true; } FileScopePtr fs = ar->findFileScope(m_include); if (fs && fs->getPseudoMain()) { if (!Option::KeepStatementsWithNoEffect) { if (ExpressionPtr rep = fs->getEffectiveImpl(ar)) { recomputeEffects(); return replaceValue(rep->clone()); } } } else { m_include = ""; } } return ExpressionPtr(); }