Store unmangled function names in the AST
This makes the code simpler across the board. There are a few cases
where mangled names still need to be generated in AST traversers, but
they are outweighed by much leaner output code for all function nodes.
BUG=angleproject:1490
TEST=angle_unittests, angle_end2end_tests
Change-Id: Id3638e0fca6019bbbe6fc5e1b7763870591da2d8
Reviewed-on: https://chromium-review.googlesource.com/461077
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/OutputGLSLBase.cpp b/src/compiler/translator/OutputGLSLBase.cpp
index b5a8b1e..fee3836 100644
--- a/src/compiler/translator/OutputGLSLBase.cpp
+++ b/src/compiler/translator/OutputGLSLBase.cpp
@@ -926,7 +926,7 @@
if (type.isArray())
out << arrayBrackets(type);
- out << " " << hashFunctionNameIfNeeded(node->getFunctionSymbolInfo()->getNameObj());
+ out << " " << hashFunctionNameIfNeeded(*node->getFunctionSymbolInfo());
out << "(";
writeFunctionParameters(*(node->getSequence()));
@@ -946,7 +946,17 @@
case EOpCallBuiltInFunction:
// Function call.
if (visit == PreVisit)
- out << hashFunctionNameIfNeeded(node->getFunctionSymbolInfo()->getNameObj()) << "(";
+ {
+ if (node->getOp() == EOpCallBuiltInFunction)
+ {
+ out << translateTextureFunction(node->getFunctionSymbolInfo()->getName());
+ }
+ else
+ {
+ out << hashFunctionNameIfNeeded(*node->getFunctionSymbolInfo());
+ }
+ out << "(";
+ }
else if (visit == InVisit)
out << ", ";
else
@@ -1196,22 +1206,17 @@
return hashName(name);
}
-TString TOutputGLSLBase::hashFunctionNameIfNeeded(const TName &mangledName)
+TString TOutputGLSLBase::hashFunctionNameIfNeeded(const TFunctionSymbolInfo &info)
{
- TString mangledStr = mangledName.getString();
- TString name = TFunction::unmangleName(mangledStr);
- if (mSymbolTable.findBuiltIn(mangledStr, mShaderVersion) != nullptr || name == "main")
- return translateTextureFunction(name);
- if (mangledName.isInternal())
+ if (info.isMain() || info.getNameObj().isInternal())
{
// Internal function names are outputted as-is - they may refer to functions manually added
// to the output shader source that are not included in the AST at all.
- return name;
+ return info.getName();
}
else
{
- TName nameObj(name);
- return hashName(nameObj);
+ return hashName(info.getNameObj());
}
}