Commit 37b697ed by Olli Etuaho Committed by Commit Bot

Only return symbol from TSymbolTable::find

Whether the symbol is built-in can be easily determined from the SymbolType stored in the symbol, it doesn't need to be returned separately. The sameScope value that could be returned from TSymbolTable::find was never used, so that can be removed as well. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I06958741ebec67d496f830a83b4f6f1359632f45 Reviewed-on: https://chromium-review.googlesource.com/891021Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent e4741fd0
......@@ -5815,16 +5815,15 @@ TIntermTyped *TParseContext::addNonConstructorFunctionCall(const TString &name,
// First find by unmangled name to check whether the function name has been
// hidden by a variable name or struct typename.
// If a function is found, check for one with a matching argument list.
bool builtIn;
const TSymbol *symbol = symbolTable.find(name, mShaderVersion, &builtIn);
const TSymbol *symbol = symbolTable.find(name, mShaderVersion);
if (symbol != nullptr && !symbol->isFunction())
{
error(loc, "function name expected", name.c_str());
}
else
{
symbol = symbolTable.find(TFunction::GetMangledNameFromCall(name, *arguments),
mShaderVersion, &builtIn);
symbol =
symbolTable.find(TFunction::GetMangledNameFromCall(name, *arguments), mShaderVersion);
if (symbol == nullptr)
{
error(loc, "no matching overloaded function found", name.c_str());
......@@ -5835,12 +5834,12 @@ TIntermTyped *TParseContext::addNonConstructorFunctionCall(const TString &name,
//
// A declared function.
//
if (builtIn && fnCandidate->extension() != TExtension::UNDEFINED)
if (fnCandidate->extension() != TExtension::UNDEFINED)
{
checkCanUseExtension(loc, fnCandidate->extension());
}
TOperator op = fnCandidate->getBuiltInOp();
if (builtIn && op != EOpNull)
if (fnCandidate->symbolType() == SymbolType::BuiltIn && op != EOpNull)
{
// A function call mapped to a built-in operation.
if (fnCandidate->getParamCount() == 1)
......@@ -5867,14 +5866,13 @@ TIntermTyped *TParseContext::addNonConstructorFunctionCall(const TString &name,
}
else
{
// This is a real function call
// This is a real function call.
TIntermAggregate *callNode = nullptr;
// If builtIn == false, the function is user defined - could be an overloaded
// built-in as well.
// if builtIn == true, it's a builtIn function with no op associated with it.
// This needs to happen after the function info including name is set.
if (builtIn)
// If the symbol type is not BuiltIn, the function is user defined - could be an
// overloaded built-in as well. if the symbol type is BuiltIn, it's a built-in
// function with no op associated with it.
if (fnCandidate->symbolType() == SymbolType::BuiltIn)
{
callNode = TIntermAggregate::CreateBuiltInFunctionCall(*fnCandidate, arguments);
checkTextureOffsetConst(callNode);
......
......@@ -139,10 +139,7 @@ const TFunction *TSymbolTable::setUserDefinedFunctionParameterNamesFromDefinitio
return firstDeclaration;
}
const TSymbol *TSymbolTable::find(const TString &name,
int shaderVersion,
bool *builtIn,
bool *sameScope) const
const TSymbol *TSymbolTable::find(const TString &name, int shaderVersion) const
{
int level = currentLevel();
TSymbol *symbol = nullptr;
......@@ -158,12 +155,8 @@ const TSymbol *TSymbolTable::find(const TString &name,
level--;
symbol = table[level]->find(name);
} while (symbol == nullptr && --level >= 0);
if (builtIn)
*builtIn = (level <= LAST_BUILTIN_LEVEL);
if (sameScope)
*sameScope = (level == currentLevel());
level--;
} while (symbol == nullptr && level >= 0);
return symbol;
}
......
......@@ -188,10 +188,7 @@ class TSymbolTable : angle::NonCopyable
const TFunction *setUserDefinedFunctionParameterNamesFromDefinition(const TFunction *function,
bool *wasDefinedOut);
const TSymbol *find(const TString &name,
int shaderVersion,
bool *builtIn = nullptr,
bool *sameScope = nullptr) const;
const TSymbol *find(const TString &name, int shaderVersion) const;
const TSymbol *findGlobal(const TString &name) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment