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, ...@@ -5815,16 +5815,15 @@ TIntermTyped *TParseContext::addNonConstructorFunctionCall(const TString &name,
// First find by unmangled name to check whether the function name has been // First find by unmangled name to check whether the function name has been
// hidden by a variable name or struct typename. // hidden by a variable name or struct typename.
// If a function is found, check for one with a matching argument list. // If a function is found, check for one with a matching argument list.
bool builtIn; const TSymbol *symbol = symbolTable.find(name, mShaderVersion);
const TSymbol *symbol = symbolTable.find(name, mShaderVersion, &builtIn);
if (symbol != nullptr && !symbol->isFunction()) if (symbol != nullptr && !symbol->isFunction())
{ {
error(loc, "function name expected", name.c_str()); error(loc, "function name expected", name.c_str());
} }
else else
{ {
symbol = symbolTable.find(TFunction::GetMangledNameFromCall(name, *arguments), symbol =
mShaderVersion, &builtIn); symbolTable.find(TFunction::GetMangledNameFromCall(name, *arguments), mShaderVersion);
if (symbol == nullptr) if (symbol == nullptr)
{ {
error(loc, "no matching overloaded function found", name.c_str()); error(loc, "no matching overloaded function found", name.c_str());
...@@ -5835,12 +5834,12 @@ TIntermTyped *TParseContext::addNonConstructorFunctionCall(const TString &name, ...@@ -5835,12 +5834,12 @@ TIntermTyped *TParseContext::addNonConstructorFunctionCall(const TString &name,
// //
// A declared function. // A declared function.
// //
if (builtIn && fnCandidate->extension() != TExtension::UNDEFINED) if (fnCandidate->extension() != TExtension::UNDEFINED)
{ {
checkCanUseExtension(loc, fnCandidate->extension()); checkCanUseExtension(loc, fnCandidate->extension());
} }
TOperator op = fnCandidate->getBuiltInOp(); TOperator op = fnCandidate->getBuiltInOp();
if (builtIn && op != EOpNull) if (fnCandidate->symbolType() == SymbolType::BuiltIn && op != EOpNull)
{ {
// A function call mapped to a built-in operation. // A function call mapped to a built-in operation.
if (fnCandidate->getParamCount() == 1) if (fnCandidate->getParamCount() == 1)
...@@ -5867,14 +5866,13 @@ TIntermTyped *TParseContext::addNonConstructorFunctionCall(const TString &name, ...@@ -5867,14 +5866,13 @@ TIntermTyped *TParseContext::addNonConstructorFunctionCall(const TString &name,
} }
else else
{ {
// This is a real function call // This is a real function call.
TIntermAggregate *callNode = nullptr; TIntermAggregate *callNode = nullptr;
// If builtIn == false, the function is user defined - could be an overloaded // If the symbol type is not BuiltIn, the function is user defined - could be an
// built-in as well. // overloaded built-in as well. if the symbol type is BuiltIn, it's a built-in
// if builtIn == true, it's a builtIn function with no op associated with it. // function with no op associated with it.
// This needs to happen after the function info including name is set. if (fnCandidate->symbolType() == SymbolType::BuiltIn)
if (builtIn)
{ {
callNode = TIntermAggregate::CreateBuiltInFunctionCall(*fnCandidate, arguments); callNode = TIntermAggregate::CreateBuiltInFunctionCall(*fnCandidate, arguments);
checkTextureOffsetConst(callNode); checkTextureOffsetConst(callNode);
......
...@@ -139,10 +139,7 @@ const TFunction *TSymbolTable::setUserDefinedFunctionParameterNamesFromDefinitio ...@@ -139,10 +139,7 @@ const TFunction *TSymbolTable::setUserDefinedFunctionParameterNamesFromDefinitio
return firstDeclaration; return firstDeclaration;
} }
const TSymbol *TSymbolTable::find(const TString &name, const TSymbol *TSymbolTable::find(const TString &name, int shaderVersion) const
int shaderVersion,
bool *builtIn,
bool *sameScope) const
{ {
int level = currentLevel(); int level = currentLevel();
TSymbol *symbol = nullptr; TSymbol *symbol = nullptr;
...@@ -158,12 +155,8 @@ const TSymbol *TSymbolTable::find(const TString &name, ...@@ -158,12 +155,8 @@ const TSymbol *TSymbolTable::find(const TString &name,
level--; level--;
symbol = table[level]->find(name); symbol = table[level]->find(name);
} while (symbol == nullptr && --level >= 0); level--;
} while (symbol == nullptr && level >= 0);
if (builtIn)
*builtIn = (level <= LAST_BUILTIN_LEVEL);
if (sameScope)
*sameScope = (level == currentLevel());
return symbol; return symbol;
} }
......
...@@ -188,10 +188,7 @@ class TSymbolTable : angle::NonCopyable ...@@ -188,10 +188,7 @@ class TSymbolTable : angle::NonCopyable
const TFunction *setUserDefinedFunctionParameterNamesFromDefinition(const TFunction *function, const TFunction *setUserDefinedFunctionParameterNamesFromDefinition(const TFunction *function,
bool *wasDefinedOut); bool *wasDefinedOut);
const TSymbol *find(const TString &name, const TSymbol *find(const TString &name, int shaderVersion) const;
int shaderVersion,
bool *builtIn = nullptr,
bool *sameScope = nullptr) const;
const TSymbol *findGlobal(const TString &name) 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