Make unique id counter a member of TSymbolTable
This makes unique id counting thread-safe.
BUG=angleproject:624
TEST=angle_unittests
Change-Id: Ie0f2c7e574470b39750d37d2181c790bc874b275
Reviewed-on: https://chromium-review.googlesource.com/570419
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/SymbolTable.cpp b/src/compiler/translator/SymbolTable.cpp
index 91404fa..c3ca928 100644
--- a/src/compiler/translator/SymbolTable.cpp
+++ b/src/compiler/translator/SymbolTable.cpp
@@ -29,9 +29,7 @@
} // anonymous namespace
-int TSymbolTable::uniqueIdCounter = 0;
-
-TSymbolUniqueId::TSymbolUniqueId() : mId(TSymbolTable::nextUniqueId())
+TSymbolUniqueId::TSymbolUniqueId(TSymbolTable *symbolTable) : mId(symbolTable->nextUniqueId())
{
}
@@ -44,7 +42,8 @@
return mId;
}
-TSymbol::TSymbol(const TString *n) : uniqueId(TSymbolTable::nextUniqueId()), name(n)
+TSymbol::TSymbol(TSymbolTable *symbolTable, const TString *n)
+ : uniqueId(symbolTable->nextUniqueId()), name(n)
{
}
@@ -281,7 +280,7 @@
TInterfaceBlockName *TSymbolTable::declareInterfaceBlockName(const TString *name)
{
- TInterfaceBlockName *blockNameSymbol = new TInterfaceBlockName(name);
+ TInterfaceBlockName *blockNameSymbol = new TInterfaceBlockName(this, name);
if (insert(currentLevel(), blockNameSymbol))
{
return blockNameSymbol;
@@ -296,7 +295,7 @@
TVariable *TSymbolTable::insertVariable(ESymbolLevel level, const TString *name, const TType &type)
{
- TVariable *var = new TVariable(name, type);
+ TVariable *var = new TVariable(this, name, type);
if (insert(level, var))
{
// Do lazy initialization for struct types, so we allocate to the current scope.
@@ -314,7 +313,7 @@
const char *name,
const TType &type)
{
- TVariable *var = new TVariable(NewPoolTString(name), type);
+ TVariable *var = new TVariable(this, NewPoolTString(name), type);
if (insert(level, ext, var))
{
if (var->getType().getBasicType() == EbtStruct)
@@ -328,7 +327,7 @@
TVariable *TSymbolTable::insertStructType(ESymbolLevel level, TStructure *str)
{
- TVariable *var = new TVariable(&str->name(), TType(str), true);
+ TVariable *var = new TVariable(this, &str->name(), TType(str), true);
if (insert(level, var))
{
var->getType().realize();
@@ -467,7 +466,7 @@
}
else
{
- TFunction *function = new TFunction(NewPoolTString(name), rvalue, op, ext);
+ TFunction *function = new TFunction(this, NewPoolTString(name), rvalue, op, ext);
function->addParameter(TConstParameter(ptype1));
@@ -532,7 +531,7 @@
const char *name)
{
insertUnmangledBuiltInName(name, level);
- insert(level, new TFunction(NewPoolTString(name), rvalue, op));
+ insert(level, new TFunction(this, NewPoolTString(name), rvalue, op));
}
TPrecision TSymbolTable::getDefaultPrecision(TBasicType type) const