bool FileScope::addFunction(AnalysisResultConstPtr ar, FunctionScopePtr funcScope) { if (ar->declareFunction(funcScope)) { FunctionScopePtr &fs = m_functions[funcScope->getScopeName()]; if (fs) { if (!m_redeclaredFunctions) { m_redeclaredFunctions = new StringToFunctionScopePtrVecMap; } auto& funcVec = (*m_redeclaredFunctions)[funcScope->getScopeName()]; if (!funcVec.size()) { fs->setLocalRedeclaring(); funcVec.push_back(fs); } funcScope->setLocalRedeclaring(); funcVec.push_back(funcScope); } else { fs = funcScope; } return true; } return false; }
bool AnalysisResult::declareFunction(FunctionScopePtr funcScope) const { assert(m_phase < AnalyzeAll); // System functions override auto it = m_functions.find(funcScope->getScopeName()); if (it != m_functions.end()) { // we need someone to hold on to a reference to it // even though we're not going to do anything with it this->lock()->m_ignoredScopes.push_back(funcScope); std::string msg; string_printf( msg, Strings::REDECLARE_BUILTIN, funcScope->getScopeName().c_str() ); funcScope->setFatal(msg); return false; } return true; }
bool ClassScope::addFunction(AnalysisResultConstPtr ar, FileScopeRawPtr fileScope, FunctionScopePtr funcScope) { FunctionScopePtr &func = m_functions[funcScope->getScopeName()]; if (func) { func->getStmt()->parseTimeFatal(fileScope, Compiler::DeclaredMethodTwice, "Redeclared method %s::%s", getScopeName().c_str(), func->getScopeName().c_str()); } func = funcScope; m_functionsVec.push_back(funcScope); return true; }
bool AnalysisResult::declareFunction(FunctionScopePtr funcScope) const { assert(m_phase < AnalyzeAll); // System functions override auto it = m_functions.find(funcScope->getScopeName()); if (it != m_functions.end()) { if (!it->second->allowOverride()) { // we need someone to hold on to a reference to it // even though we're not going to do anything with it this->lock()->m_ignoredScopes.push_back(funcScope); return false; } } return true; }