Make TVariable type immutable
This enables using constexpr types for built-in variables and some of
the variables created in AST transformations.
BUG=angleproject:2267
TEST=angle_unittests
Change-Id: Ie85b3c9872a071a7c023ced013b14ad91cff7cee
Reviewed-on: https://chromium-review.googlesource.com/868134
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/RemoveDynamicIndexing.cpp b/src/compiler/translator/RemoveDynamicIndexing.cpp
index 36300ed..05593a0 100644
--- a/src/compiler/translator/RemoveDynamicIndexing.cpp
+++ b/src/compiler/translator/RemoveDynamicIndexing.cpp
@@ -14,6 +14,7 @@
#include "compiler/translator/IntermNodePatternMatcher.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/IntermTraverse.h"
+#include "compiler/translator/StaticType.h"
#include "compiler/translator/SymbolTable.h"
namespace sh
@@ -58,7 +59,7 @@
return nameSink.str();
}
-TIntermSymbol *CreateBaseSymbol(const TType &type, TSymbolTable *symbolTable)
+TIntermSymbol *CreateBaseSymbol(const TType *type, TSymbolTable *symbolTable)
{
TString *baseString = NewPoolTString("base");
TVariable *baseVariable =
@@ -69,16 +70,17 @@
TIntermSymbol *CreateIndexSymbol(TSymbolTable *symbolTable)
{
TString *indexString = NewPoolTString("index");
- TVariable *indexVariable = new TVariable(
- symbolTable, indexString, TType(EbtInt, EbpHigh, EvqIn), SymbolType::AngleInternal);
+ TVariable *indexVariable =
+ new TVariable(symbolTable, indexString, StaticType::Get<EbtInt, EbpHigh, EvqIn, 1, 1>(),
+ SymbolType::AngleInternal);
return new TIntermSymbol(indexVariable);
}
TIntermSymbol *CreateValueSymbol(const TType &type, TSymbolTable *symbolTable)
{
TString *valueString = NewPoolTString("value");
- TType valueType(type);
- valueType.setQualifier(EvqIn);
+ TType *valueType = new TType(type);
+ valueType->setQualifier(EvqIn);
TVariable *valueVariable =
new TVariable(symbolTable, valueString, valueType, SymbolType::AngleInternal);
return new TIntermSymbol(valueVariable);
@@ -179,15 +181,15 @@
std::string functionName = GetIndexFunctionName(type, write);
TIntermFunctionPrototype *prototypeNode = CreateInternalFunctionPrototypeNode(func);
- TType baseType(type);
+ TType *baseType = new TType(type);
// Conservatively use highp here, even if the indexed type is not highp. That way the code can't
// end up using mediump version of an indexing function for a highp value, if both mediump and
// highp values are being indexed in the shader. For HLSL precision doesn't matter, but in
// principle this code could be used with multiple backends.
- baseType.setPrecision(EbpHigh);
- baseType.setQualifier(EvqInOut);
+ baseType->setPrecision(EbpHigh);
+ baseType->setQualifier(EvqInOut);
if (!write)
- baseType.setQualifier(EvqIn);
+ baseType->setQualifier(EvqIn);
TIntermSymbol *baseParam = CreateBaseSymbol(baseType, symbolTable);
prototypeNode->getSequence()->push_back(baseParam);