void FunctionCall::markRefParams(FunctionScopePtr func, const std::string &fooBarName) { ExpressionList ¶ms = *m_params; if (func) { int mpc = func->getMaxParamCount(); for (int i = params.getCount(); i--; ) { ExpressionPtr p = params[i]; if (i < mpc ? func->isRefParam(i) : func->isReferenceVariableArgument()) { p->setContext(Expression::RefValue); } else if (i < mpc && p->hasContext(RefParameter)) { Symbol *sym = func->getVariables()->addSymbol(func->getParamName(i)); sym->setLvalParam(); sym->setCallTimeRef(); } } } else if (Option::WholeProgram && !m_origName.empty()) { FunctionScope::FunctionInfoPtr info = FunctionScope::GetFunctionInfo(m_origName); if (info) { for (int i = params.getCount(); i--; ) { if (info->isRefParam(i)) { m_params->markParam(i); } } } // If we cannot find information of the so-named function, it might not // exist, or it might go through __call(), either of which cannot have // reference parameters. } else { for (int i = params.getCount(); i--; ) { m_params->markParam(i); } } }
void FunctionScope::RecordFunctionInfo(std::string fname, FunctionScopePtr func) { VariableTablePtr variables = func->getVariables(); if (Option::WholeProgram) { Lock lock(s_refParamInfoLock); FunctionInfoPtr &info = s_refParamInfo[fname]; if (!info) { info = std::make_shared<FunctionInfo>(); } if (func->isStatic()) { info->setMaybeStatic(); } if (func->isRefReturn()) { info->setMaybeRefReturn(); } if (func->isReferenceVariableArgument()) { info->setRefVarArg(func->getMaxParamCount()); } for (int i = 0; i < func->getMaxParamCount(); i++) { if (func->isRefParam(i)) info->setRefParam(i); } } auto limit = func->getDeclParamCount(); for (int i = 0; i < limit; i++) { variables->addParam(func->getParamName(i), AnalysisResultPtr(), ConstructPtr()); } }
void FunctionScope::RecordRefParamInfo(string fname, FunctionScopePtr func) { RefParamInfoPtr info = s_refParamInfo[fname]; if (!info) { info = RefParamInfoPtr(new RefParamInfo()); s_refParamInfo[fname] = info; } if (func->isReferenceVariableArgument()) { info->setRefVarArg(func->getMaxParamCount()); } VariableTablePtr variables = func->getVariables(); for (int i = 0; i < func->getMaxParamCount(); i++) { if (func->isRefParam(i)) info->setRefParam(i); variables->addParam(func->getParamName(i), TypePtr(), AnalysisResultPtr(), ConstructPtr()); } }