translator: Store symbol type in TField.
This allows us to keep a separate symbol type for each field in a
struct. This can allow us to assign internal names to struct types.
It could also allow us to add internal fields to user defined stucts.
Bug: angleproject:2665
Change-Id: I6a129107d9db66c54b98b07684c3ead5801712ba
Reviewed-on: https://chromium-review.googlesource.com/1101565
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputGLSLBase.cpp b/src/compiler/translator/OutputGLSLBase.cpp
index 14140eb..ea25855 100644
--- a/src/compiler/translator/OutputGLSLBase.cpp
+++ b/src/compiler/translator/OutputGLSLBase.cpp
@@ -581,7 +581,7 @@
const TIntermConstantUnion *index = node->getRight()->getAsConstantUnion();
const TField *field = structure->fields()[index->getIConst(0)];
- out << hashFieldName(structure, field->name());
+ out << hashFieldName(field);
visitChildren = false;
}
break;
@@ -595,7 +595,7 @@
const TField *field = interfaceBlock->fields()[index->getIConst(0)];
ASSERT(interfaceBlock->symbolType() == SymbolType::UserDefined ||
interfaceBlock->name() == "gl_PerVertex");
- out << hashFieldName(interfaceBlock, field->name());
+ out << hashFieldName(field);
visitChildren = false;
}
break;
@@ -1115,18 +1115,15 @@
return HashName(symbol, mHashFunction, &mNameMap);
}
-ImmutableString TOutputGLSLBase::hashFieldName(const TSymbol *containingStruct,
- const ImmutableString &fieldName)
+ImmutableString TOutputGLSLBase::hashFieldName(const TField *field)
{
- if (containingStruct->symbolType() == SymbolType::UserDefined ||
- containingStruct->symbolType() == SymbolType::Empty)
+ ASSERT(field->symbolType() != SymbolType::Empty);
+ if (field->symbolType() == SymbolType::UserDefined)
{
- return HashName(fieldName, mHashFunction, &mNameMap);
+ return HashName(field->name(), mHashFunction, &mNameMap);
}
- else
- {
- return fieldName;
- }
+
+ return field->name();
}
ImmutableString TOutputGLSLBase::hashFunctionNameIfNeeded(const TFunction *func)
@@ -1169,7 +1166,7 @@
const TField *field = fields[i];
if (writeVariablePrecision(field->type()->getPrecision()))
out << " ";
- out << getTypeName(*field->type()) << " " << hashFieldName(structure, field->name());
+ out << getTypeName(*field->type()) << " " << hashFieldName(field);
if (field->type()->isArray())
out << ArrayString(*field->type());
out << ";\n";
@@ -1254,7 +1251,7 @@
if (writeVariablePrecision(field->type()->getPrecision()))
out << " ";
- out << getTypeName(*field->type()) << " " << hashFieldName(interfaceBlock, field->name());
+ out << getTypeName(*field->type()) << " " << hashFieldName(field);
if (field->type()->isArray())
out << ArrayString(*field->type());
out << ";\n";