Track whether a name is internal to ANGLE in a separate class
The AST contains identifiers in a few different places: besides symbols,
there are also function names, which show up in function signatures
and function calls. Any of these can be coming either from the original
shader or from inside ANGLE. A class that encapsulates a string and its
internalness will be useful for implementing a unified way of handling
all names in shader translation. Start implementing this by splitting
the functionality out of TSymbol.
TEST=angle_unittests
BUG=angleproject:1116
Change-Id: I0a1b5936dcccd0d5fc1c0c13c712102fbfff2a79
Reviewed-on: https://chromium-review.googlesource.com/291280
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index e094db2..b91a4a8 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -1391,13 +1391,9 @@
mUsesFragDepth = true;
out << "gl_Depth";
}
- else if (node->isInternal())
- {
- out << name;
- }
else
{
- out << Decorate(name);
+ out << DecorateIfNeeded(node->getName());
}
}
}
@@ -2849,25 +2845,27 @@
TString OutputHLSL::argumentString(const TIntermSymbol *symbol)
{
TQualifier qualifier = symbol->getQualifier();
- const TType &type = symbol->getType();
- TString name = symbol->getSymbol();
+ const TType &type = symbol->getType();
+ const TName &name = symbol->getName();
+ TString nameStr;
- if (name.empty()) // HLSL demands named arguments, also for prototypes
+ if (name.getString().empty()) // HLSL demands named arguments, also for prototypes
{
- name = "x" + str(mUniqueIndex++);
+ nameStr = "x" + str(mUniqueIndex++);
}
- else if (!symbol->isInternal())
+ else
{
- name = Decorate(name);
+ nameStr = DecorateIfNeeded(name);
}
if (mOutputType == SH_HLSL11_OUTPUT && IsSampler(type.getBasicType()))
{
- return QualifierString(qualifier) + " " + TextureString(type) + " texture_" + name + ArrayString(type) + ", " +
- QualifierString(qualifier) + " " + SamplerString(type) + " sampler_" + name + ArrayString(type);
+ return QualifierString(qualifier) + " " + TextureString(type) + " texture_" + nameStr +
+ ArrayString(type) + ", " + QualifierString(qualifier) + " " + SamplerString(type) +
+ " sampler_" + nameStr + ArrayString(type);
}
- return QualifierString(qualifier) + " " + TypeString(type) + " " + name + ArrayString(type);
+ return QualifierString(qualifier) + " " + TypeString(type) + " " + nameStr + ArrayString(type);
}
TString OutputHLSL::initializer(const TType &type)